Error with .delimit .Params.tags

Something bizarre is going on with the latest Hugo build (0.20.5) and .delimit .Params.tags

In /default/single.html
I have this

<div class="content {{ delimit .Params.tags " " }}">
                        {{ .Content }}
                        </div>

When I run hugo server the page is generated as intended with said <div> having a post’s tags as classes.

But in the terminal I’m getting the following error

Error while rendering “page”: template: theme/_default/single.html:53:53: executing “theme/_default/single.html” at <delimit .Params.tags…>: error calling delimit: can’t iterate over

Why the error message? I mean the page is getting rendered like it’s supposed to be.

Looks like that Hugo doesn’t like the delimit function in a single.html that makes use of if eq .Section to render different things according to category.

Anyway I managed to make the error go away by using delimit like this at the beginning of my template:

<section class='wrapper{{if eq .Section "art-fairs"}} permalink {{ delimit .Params.tags " " }}{{end}}{{if eq .Section "artists"}} permalink artists{{end}}{{if eq .Section "exhibitions"}} permalink{{end}}'>

Use .IsPage to check if tags are available.

1 Like

I just migrated a project that was deployed fine with Hugo 0.31 today to Hugo 0.36.1 and it failed.

I went through the release notes of every version since Hugo 0.32.

It seems that the taxonomies related fix in Hugo 0.33 made Hugo complain about not being able to iterate over nil using delimit, even though I had tags everywhere.

After some head scratching I wrapped the delimit function in a {{ if .IsPage }} condition and the error finally went away. The site is again functional like it used to be.

1 Like