I have one website, with many authors and a lot of posts/articles. I migrated from WP to Hugo about 6 months ago. To develop with Hugo, I just run hugo server or hugo server --ignoreCache --disableLiveReload, but the time of build is very long. See the statistics of Hugo below:
Built site for language pt-br:
0 of 1 draft rendered
0 future content
0 expired content
1771 regular pages created
3128 other pages created
0 non-page files copied
0 paginator pages created
240 authors created
1219 tags created
98 categories created
total in 25103 ms
You can save 777 ms by using partialCached for the sidebar partial, and you can probably also do that for the footer.
You can save a lot by doing less work in theme/post/single.html – you need to look at the related feature in Hugo to replace the intersect construct. https://gohugo.io/content-management/related/
Wow!
I tried to use the partialCached another time, but, without tips of --templateMetrics and --templateMetricsHints, I did not see any changes. Now, I’m using the partialCached in Header, Footer and Sidebar.
But, the tip of related feature is gold. Thank you a lot!
Built site for language pt-br:
0 draft content
0 future content
0 expired content
1775 regular pages created
3134 other pages created
0 non-page files copied
0 paginator pages created
240 authors created
1219 tags created
98 categories created
total in 2181 ms
Just to resume the changes:
Modify the related posts script to original solution of Hugo
Just to know: I remove the Tags from my taxonomies. I realize that I use tags just to make the Related Posts. But, I configure the Related to take Categories first, title in second after authors. Removing the Tags Taxonomy, the build on the server got much faster. This decrease the number of other pages created from 3134 to 714.
This gives me more freedom to organize where I can use the partialCached without break some page information. In past post, I said that I was using partialCached in Sidebar and Header. Doing this, I can get just 2181ms to build in development environment, but I can’t use cached in this partials because the info in that areas changes sometimes. So, I rollback the partial default include, but the build increase to something like ~5000ms. Removing the tags like I said before, I get ~2500ms. Results:
Built site for language pt-br:
0 draft content
0 of 2 futures rendered
0 expired content
1779 regular pages created
714 other pages created
0 non-page files copied
0 paginator pages created
107 categories created
241 authors created
total in 2696 ms