Hey! I’m now adding support for Micropub and some other features from IndieWeb such as Webmentions, IndieAuth and other stuff and using my website as my primary platform to publish my content and then POSSE it (post on your own site, syndicate elsewhere) on other places.
I’ve actually written a post about the journey so far and the problems I’ve been hitting. One of them is related to Hugo’s speed which isn’t usually a complaint and the theme complexity (hopefully I’ll be able to cut it down a bit soon).
As of right now, each build takes ~3s on the server and ~1s on my laptop with about ~950 posts. I don’t want to wait that much time when I just want to post a like or a repost so I was wondering if running hugo --watch in production is feasible.
During development, I’ve hit some problems with the watch mode but I think they might be related to heavy changes in the layouts and not to the website contents themselves.
What do you think? Is hugo --watch a good option for a production website that can change at any time? Or is that a bad idea?
It is a static website generator. I’m just trying to find a way to regenerate it when there might be a lot of changes in a short time period. And thus I’m thinking about either using hugo --watch or moving out of Hugo and making a really simple server-side rendering. However, I would prefer to keep my website being served with static pages.
Right I just tested the above, since I had never used hugo --watch before.
I went ahead and deleted a content file, the site was regenerated in the terminal but the generated HTML of said content file was not removed from the /public/ folder
Hopefully someone more knowledgeable than I can advice you whether running hugo --watch as a process on your server is a viable option to rebuild a Hugo project on demand.
The same behavior with deletion happens when running with server too. If you try to change the content, you’ll see the correctly regenerated page. Not sure if it’s a bug or not.
The thing is that basically you are talking about incremental builds. You cannot achieve these just with Hugo. You might have better luck experimenting with Netlify.
There is another thread similar to yours from 2017 and it doesn’t seem like hugo --watch is the way to go.
That’s sad. I’ll probably build my own platform for this. Some selfdogfooding for learning ahah. Netlify is not a static website builder, they just store your content and call whatever commands you want. I was using them, but if I do I have to wait more time: git commit & git push & netlify notices it & netlify calls hugo & hugo runs & live!
Also I saw @bep saying that it is really easy to write uneffective (ineffective?) Go templates. I wonder if there are any tips and tricks not to fall into some traps. I searched but couldn’t find any information on the subject.
From personal experience I found that too many shortcodes can slow down a project.
I have seen an improvement in performance by updating the content files of my projects to use the new Markdown Render Hooks
Too many Data files will slow down a build. There is a GitHub issue about creating Pages from Data files, in the main Hugo repo, that will be implemented at some point.
Hugo’s Related Content is the recommended way to create page links to related pages.
When using Resources to create various image sizes, committing the generated resources directory in the project’s git repo will save build time.
Template inheritance should be used throughout a project. Taking advantage of partialCached whenever possible saves build time.