Hi there, i’d like to talk about liveload.
It automatically checks for updates / new files and rebuild the website after it detects these things.
But what if my website has 2000 posts and i just change one word in one file? The liveload will automatically rebuild the entire website, not only the “affected” file.
Is it possibile to make the liveload working only when it is really needed and just for the affected files?
How it works (or should work) is:
- If files in static is changed (image, css …), “a soft” livereload is triggered in the browser. No rebuild
- For changes in /content and /data and /layout (in project and theme) => full site rebuild.
What you want is possible, but very expensive – and not done until really, really necessary. 1000 pages should clock in at at second or two.
I know the Jekyll crowd is doing some stuff in this area right now – but then, they are living with minutes generation time for the same data.
You are confusing a couple terms.
1. Watching
Hugo inspects for changes on the filesystem and rebuilds the site when a change is detected. Currently Hugo rebuilds the entire site vs incremental rebuilds.
It’s not that incremental rebuilds are impossible, just that they are hard to do right, and often add additional overhead to the entire build process. Additionally for things like template changes or even just changing taxonomies or dates they require rendering a large portion of the site anyway.
We’ve instead just focused to date on overall performance and you’ll find that Hugo is much faster building the entire site than virtually any other generator is at even the incremental rebuild.
##2. Live reload
Live reload is a really useful addition to hugo that automatically reloads the open pages in the browser whenever the site is generated. This is done only for open pages. As @bep writes, some files don’t even require a reload and instead will dynamically update the pages.
Yeah sorry for the confusion, i was talking about the 2nd point.
How should it be added? I really don’t like to see the entire website being rebuilt if i change just a comma in 1 file.
Thanks for the reply!
@bep it seems you deleted your comment, by the way now the system should be working that way:
Check if there are updates in the folder => rebuild the entire website
Souldn’t be better to do this?
Check if there are updates in the folder => detect the affected file => build only the influenced file
It seems to be more correct and might be better for people who has got many many pages, what do you think about it? Is it possible to do?
Now you are talking about the first point above.
I starting writing a post, deleted it because there is not simple solution to point 1 above. It can be done, but not in a line or two.
There may be improvements to point 2 as well, but I suspect you have been thinking about point 1 all the time, so lets not spend too much energy thinking about it.