Hugo

I haven’t touched the site for pretty long time, but recently after re-installing Linux I’ve decided to update Hugo to latest version, and… found out that my site was broken in serveral places.

  1. I had to move most of the params in language sections to params sub-section. Actually, hugo serve warns about wrongly placed parameters, so it’s not a big problem.
  2. I’ve removed taxonomyTerm from the outputs section in config. As I understood, it’s all merged with taxonomy now, so separate parameter doesn’t make sense.
  3. I had to make category keys in theme to lower case. 0.123.3 has added the capitalizeListTitles option (i.e. font-patching became Font-Patching). For some people it’s conveinent, but for me it broke localization, since it was based on lowercased keys. In truth, making keys lowercased was a rushed decision, because I could just disable an option, but at some point there could be a problem when something somewhere will be in wrong case, and will break everything, so it’s for the better.

But now everything is generated with fresh Hugo 0.126.1, and works as expected. I think I’ll write a theme for Hugo sometime, but I think it won’t happen soon.

Since I’ve started localization talk, this note will be devoted to localization. To be honest, I’m not sure since what version this happened, but localization in Hugo has greatly stepped forward.

First, Hugo now natively supports plurals for many languages. All thanks to https://github.com/gohugoio/go-i18n module (fork of https://github.com/nicksnyder/go-i18n ). Usage is very simple: create reqired keys in localization file and translate them. Here’s current list for reference (with two-letter language codes): https://github.com/gohugoio/go-i18n/blob/main/v2/internal/plural/codegen/plurals.xml

Second, Hugo can now localize dates through time.Format DATE_FORMAT DATE. I’ve rewritten templates a little, and now places with dates from these:

{{- with .Site.Params.dateformat | default "2006-01-02" | .PublishDate.Format -}}

became these:

{{- with time.Format (.Site.Params.dateformat | default "2006-01-02") .PublishDate -}}

Category and meta tags localization I had to done on my own. They may not fully work with new section though, but I’ll fix it sometime.