Error when using the tag cache


when I use the tag “Cache” in the front matter area of an article (, the creation of the web page terminates with the following error message.

Error: Error building site: failed to render pages: render of "page" failed: "/home/laythos/repository/spielwiese.hg/themes/GythaOgg/layouts/_default/single.html:12:9": execute of template failed: template: _default/single.html:12:9: executing "main" at <partial "taxonomy.html" .>: error calling partial: "/home/laythos/repository/spielwiese.hg/themes/GythaOgg/layouts/partials/taxonomy.html:14:35": execute of template failed: template: partials/taxonomy.html:14:35: executing "partials/taxonomy.html" at <.Params.tags>: range can't iterate over Cache

All the other tags I have used have worked fine so far.

Is the problem with my theme? If so, what am I doing wrong? Or is this a bug in Hugo?

I guess it just an YAML format issue that the tags should be an array instead of string.

Change the

tags: Cache


  - Cache

@razon is correct. The error is unrelated to the word “cache”.

You can only do this when when Params.tags is an array:

{{ range .Params.tags }}
{{ end }}

Hugo throws the error because, on one or more of your pages, .Params.tags is not an array.

The .GetTerms method is much easier to use, and doesn’t care whether the front matter value is scalar or an array.

{{ range .GetTerms "tags" }}
  <a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a>
{{ end }}
1 Like

Hello @razon and @jmooring,

I’m a real dumbass from time to time.

So far I had used the solution suggested by razon for every article with more tags. For exampleälschte-usb-sticks-erkennen/

In this case, I didn’t use the dash at all. And that during countless attempts. In my mother tongue there is a saying that you can’t see the wood for the trees.

I have now solved it as follows.

<div class="article-tag">
	{{ range $k, $v := .GetTerms "tags" }}
		{{- if $k }}&nbsp;|&nbsp;{{ end }}
		<a href="{{ .RelPermalink }}" rel="tag">{{ .LinkTitle }}</a>
	{{- end }}

Thank you very much to both of you.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.