HUGO

Taxonomy case changes in 0.55

I last built my blog with Hugo 0.52. I’m trying to bring it kicking and screaming into the modern world, or at least up to 0.68.3 (which is the version shipped in Ubuntu 20.04 LTS).

One thing that changed in 0.55 is

preserveTaxonomyNames configuration option is removed. Use .Page.Title.

This makes my taxonomy list pages and my RSS feeds for tags change their titles like this

--- /tmp/git-difftool.1qRAFq/left/tags/vim/index.xml    2020-05-22 17:17:45.739908914 +0300
+++ /tmp/git-difftool.1qRAFq/right/tags/vim/index.xml   2020-05-22 17:17:45.739908914 +0300
@@ -1,9 +1,9 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes" ?>
 <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
   <channel>
-    <title>Vim on Random notes from mg</title>
+    <title>vim on Random notes from mg</title>
     <link>https://mg.pov.lt/blog/tags/vim.html</link>
-    <description>Recent content in Vim on Random notes from mg</description>
+    <description>Recent content in vim on Random notes from mg</description>
     <generator>Hugo -- gohugo.io</generator>
     <language>en-us</language>
     <managingEditor>marius@gedmin.as (Marius Gedminas)</managingEditor>

I never actually used that option, so presumably I was using its default value of false. Indeed, if I go back to Hugo 0.54 and set preserveTaxonomyNames to true, I get the same output as I get on 0.55.
(My content front matter has all the tags spelled out in lower case.)

The template for generating RSS feeds looks like this:

    <title>{{ if eq  .Title  .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{.}} on {{ end }}{{ .Site.Title }}{{ end }}</title>
    <link>{{ .Permalink }}</link>
    <description>Recent content {{ if ne  .Title  .Site.Title }}{{ with .Title }}in {{.}} {{ end }}{{ end }}on {{ .Site.Title }}</description>

It looks like the value of .Title has changed in 0.55, and I’ve no idea how to restore previous behavior.
Well, for the RSS feeds I can do that by updating the RSS template to filter the title through | humanize, but I don’t know what to do about taxonomy list pages.

Solutions I’ve considered and rejected:

  • changing the capitalization of tags in my content (tedious, besides I want them lower-case in other contexts)
  • adding a | humanize in partials/header.html (this destroys regular blog page titles)
  • getting used to the new capitalization (the aesthetics are wrong, and this makes git diff in gh-pages unreadable)

I think the simplest solution probably would be to add a conditional in the header to distinguish if this is used inside a taxonomy index or some other page, and conditionally add | humanize. I’ve no idea how to do that. I would prefer not to duplicate the entire template.

Help?

I suppose that you can try configuring the titleCaseStyle and see what happens.

OR

You can use this simple 3rd party tool that allows for mass editing of tags in Hugo post -requires a local Go installation-