Hugo 0.29

hugo
metrics
caching
Tags: #<Tag:0x00007f21aeaa9868> #<Tag:0x00007f21aeaa9728> #<Tag:0x00007f21aeaa95e8>

#1

Hugo 0.29 adds “template metrics”. Specifically, it is a flag at run time that outputs some stats on how effective one’s templates are. For instance, when I run hugo --templateMetrics --theme=heather-hugo at this point in time, my output is:

Started building sites ...

Template Metrics:

     cumulative       average       maximum         
       duration      duration      duration  count  template
     ----------      --------      --------  -----  --------
    34.828731ms    1.514292ms    7.748809ms     23  _default/single.html
     9.906438ms     396.257µs    6.555435ms     25  theme/partials/foot.html
     6.210713ms     258.779µs     671.475µs     24  theme/partials/head.html
      3.45455ms     3.45455ms     3.45455ms      1  _default/list.updates.xml
      3.43923ms     3.43923ms     3.43923ms      1  sitemap.xml
     1.844002ms       73.76µs     291.992µs     25  partials/piwik.html
      867.411µs     867.411µs     867.411µs      1  _default/rss.xml
      660.607µs     165.151µs     459.348µs      4  partials/discourse.html
      348.891µs     348.891µs     348.891µs      1  index.html
      242.637µs     242.637µs     242.637µs      1  theme/404.html
      199.941µs     199.941µs     199.941µs      1  partials/homehead.html

Built site for language en:
0 of 6 drafts rendered
0 future content
0 expired content
1235 regular pages created
54 other pages created
0 non-page files copied
0 paginator pages created
35 tags created
10 categories created
total in 272 ms

See those µs? That stands for microsecond, or one millionth of a second. I am guessing my build time is okay, since most of those templates are counted in µs!

Notice how I pass the theme flag, --theme=heather-hugo? That is because I am not currently designating a theme in my config.

Because I have to manually add that when I build the site it got me thinking about comparing the metrics of different themes! Just run it multiple time, setting a different theme, and you can see how they compare building your own site.

But really, noHTTPCache

I just posted about 0.28, in part because I am a little behind, but this was also a quick release.

The real reason this release comes so fast after the last one is to change the default value for the new noHTTPCache flag, which gives away too much performance to make sense as a default value.

I didn’t have a chance to use the noHTTPCache flag, but apprently it has performance issues; in the Hugo 0.28 release notes it recommended --noHTTPCache=false to keep the old behavior, but that is made the default again.

bep explains, The noHTTPCache is just relevant for the hugo dev server. I had this site with a rather big JSON search index which suddenly got very sluggish, and I noticed that Chrome downloaded the entire index on every page load instead of using the 304 Not Modified status.

Thoughts

I haven’t gotten started with actual theme development in Hugo yet, just modding a theme to meet my minimal needs for now. But I’ll take a closer look at both of these changes (templateMetrics and noHTTPCache) when I do.


This is a companion discussion topic for the original entry at https://interi.org/notes/hugo-0.29/