Long story short, on the production server my website was taking around 70 seconds to build because I was using {{ partial “header.html” . }} and {{ partial “footer.html” . }}
After I rewrote the code to use a single baseof.html file, it took on average 10 seconds less:
| EN | PT
+------------------+------+------+
Pages | 2555 | 1473
Paginator pages | 856 | 458
Non-page files | 2680 | 1896
Static files | 708 | 708
Processed images | 6722 | 4242
Aliases | 430 | 16
Sitemaps | 2 | 1
Cleaned | 0 | 0
Total in 64427 ms
I’m still trying to pin point other bottlenecks, but this was already a good win for such a small change.
2 Likes
regis
April 12, 2018, 7:57pm
2
70s is a lot even with 2000+ pages.
Have you tried hugo --templateMetrics
/ --templateMetricsHints
The images may play a part…
Curious @brunoamaral Did you put all the logic for those two partials into your baseof template then?
Also, you probably know this, but partialCached
may help with those type of templates, too.
There wasn’t much logic to move @budparr , you can see it here: https://github.com/brunoamaral/future-imperfect-DI/commit/2adc43934ac944400fec5410b7374a5a05930c23#diff-85bb8e3591563d3f106add8a8e301405
@regis I think the bottleneck comes from the way I rely heavily on sections. I did run templateMetrics and it helped to set some partials as cachePartial : https://pastebin.com/raw/x07ykJ48
regis
April 13, 2018, 1:16pm
5
No chance your full repo is on GitHub? I recently got interested into optimizing build time and wondered if you’d let me experiment with your project.
I am curious as if this instagram partial rely on an api of some sort.
Yes it is on github, just not public because it contains some unpublished content. Wouldn’t mind sharing if you really want to take a look.
The instagram content is retrieved with a bash script.
regis
April 13, 2018, 1:47pm
7
If you don’t mind me looking and then come back saying: “Sorry northing I can do ” (common scenario) you can add my github handle to it: regisphilibert
I’ve managed to speed up the build and it’s down to 48 seconds. In a nutshell:
I was listing content in pages where it wasn’t used
The code had 3 different versions of list.html that I managed to merge into one
Cleaned up empty categories
moved as much as I could to baseof.html, like the menu.html partial
reduced some “where” functions by using variables
removed template files that were not being used
made a better use of .Data, i was using “where” in templates that don’t need it. like list.html.
| EN | PT
+------------------+------+------+
Pages | 2528 | 1445
Paginator pages | 383 | 297
Non-page files | 2673 | 1868
Static files | 708 | 708
Processed images | 6730 | 4243
Aliases | 429 | 15
Sitemaps | 2 | 1
Cleaned | 0 | 0
Total in 47976 ms
3 Likes