hjr265.me / blog /

Strange Hugo Bug and How to Work Around It

November 15, 2023 #100DaysToOffload #Hugo

I was about to deploy my site with the latest blog post this morning and found Hugo broken. Or, my Hugo config.toml is broken. It depends on how you want to look at it.

I ran hugo deploy and bam! I see an internal template error.

ERROR render of "taxonomy" failed: template: _internal/_default/rss.xml:3:9: executing "_internal/_default/rss.xml" at <site>: can't evaluate field email in type string

According to pacman, the package manager on Arch Linux, I received an update for Hugo yesterday.

The error message indicated that the built-in rss.xml template is trying to use a field named email.

So I looked up the _default/rss.xml file on GitHub.

On line 3, Hugo is interpolating the field email from params.author in config.toml.

But my params.author is a string, my name, not an object.

I noticed a contributor to the project already added a fix for this to the Hugo repository since then. But the version I have installed on my computer does not have the fix. It has the bug.

To work around this issue, I had to update the config.toml file to have an object for the params.author field:

1
2
3
4
5
6
[params]
github = "hjr265"

[params.author]
name  = "Mahmud Ridwan"
email = "m@hjr265.me"

Instead of:

1
2
3
[params]
author = "Mahmud Ridwan"
github = "hjr265"

This post is 93rd of my #100DaysToOffload challenge. Want to get involved? Find out more at 100daystooffload.com.


comments powered by Disqus