Before I start to set up a clever™ system that copies my content into the content folder on grunt netlify-setup I wondered if there is a way to define content folders per “environment” (dev/production). I have about 2000 old blog entries that slow down recreation of the site in hugo server to (best case) 30 seconds. Because I work quite often still on the design, I wonder if it’s possible to maybe have just 10 posts in one content folder for hugo server to just speed things up and all other (or all) posts in another content folder for the production environment which then grabs content from two folders?
If that is not possible, what would your approach be? I am thinking about a simple copy job when building my site on netlify.
You shouldn’t need to do that if you do development while running hugo server. By default (unless you pass the --disableFastRender switch or set that variable in site config), the FastRender feature will cause hugo server to render only the last few touched files, making most of the site functional and accessible.
I don’t pass the fastrender parameter. Still… it’s extremely slow. If I change content files it’s between 40 to 70 seconds, changing template files sometimes goes up to 120 seconds. Not sure. I weeded out all unused templates recently.
I now run it through --templateMetrics --templateMetricsHints and it looks like though it runs through all my posts that goes through fast. what takes time are the archive pages which get recreated each time (home.html and pagination.html)?
Yea, there is something sub-optimal with your site (rendering the home page 399 times sounds odd … I assume there is pagination going on here, but there seem to be some expensive stuff going on there), but it is hard to tell without the source.
I also wonder why some paths in that debugging table are relative and some are from root. is that an indicator or just how hugo finds things?
The content was imported from WordPress and only in /content/2018/did I start to use some packages… the rest needs some re-work - not sure if that is relevant.
I did that and sped up by about 50%. Also: It appears that less partials = more speed. I moved all partials like post-head, meta lines and so on into their respective parent templates (home.html, list.html, post.html etc.)
One thing I am not sure about but it felt as if things sped up: removing Go template comments ({{/* commen */}}) containing Go template code ({{/* {{ some Go tag }} */}}) made things faster. My guess is that the inner code is executed and then ignored… or it’s just my imagination.
I am now at around 15 seconds per rebuild.
PS: and I am aware that this post is way off-topic by now.