# Error when using the tag cache

**URL:** <https://discourse.gohugo.io/t/error-when-using-the-tag-cache/43041>\
**Category:** support\
**Created:** [February 19, 2023, 12:34pm UTC](https://discourse.gohugo.io/t/error-when-using-the-tag-cache/43041 "2023-02-19T12:34:31Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fryboyter](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/fryboyter/32/26114_2.png) [@Fryboyter](https://discourse.gohugo.io/u/Fryboyter)\
**Post date:** [February 19, 2023, 12:34pm UTC](https://discourse.gohugo.io/t/error-when-using-the-tag-cache/43041/1 "2023-02-19T12:34:31Z")

</div>

- Hugo v0.110.0+extended linux/amd64 BuildDate=unknown
- Arch Linux completely updated
- Repository: [https://codeberg.org/Fryboyter/spielwiese](https://codeberg.org/Fryboyter/spielwiese)

Hello,

when I use the tag “Cache” in the front matter area of an article ([https://codeberg.org/Fryboyter/spielwiese/raw/branch/main/content/posts/debug/index.en.md](https://codeberg.org/Fryboyter/spielwiese/raw/branch/main/content/posts/debug/index.en.md)), 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?

---

<div class="post-metadata">

**Author:** ![razon](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/razon/32/14882_2.png) [@razon](https://discourse.gohugo.io/u/razon)\
**Post date:** [February 19, 2023, 1:30pm UTC](https://discourse.gohugo.io/t/error-when-using-the-tag-cache/43041/2 "2023-02-19T13:30:02Z")

</div>

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

Change the

```yaml
tags: Cache

```

to

```yaml
tags:
  - Cache

```

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [February 19, 2023, 6:41pm UTC](https://discourse.gohugo.io/t/error-when-using-the-tag-cache/43041/3 "2023-02-19T18:41:16Z")

</div>

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

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

```auto
{{ 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.

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

```

---

<div class="post-metadata">

**Author:** ![Fryboyter](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/fryboyter/32/26114_2.png) [@Fryboyter](https://discourse.gohugo.io/u/Fryboyter)\
**Post date:** [February 24, 2023, 5:28pm UTC](https://discourse.gohugo.io/t/error-when-using-the-tag-cache/43041/4 "2023-02-24T17:28:47Z")

</div>

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 [https://codeberg.org/Fryboyter/hugo/raw/branch/main/content/posts/2023/gefälschte-usb-sticks-erkennen/index.md](https://codeberg.org/Fryboyter/hugo/raw/branch/main/content/posts/2023/gef%C3%A4lschte-usb-sticks-erkennen/index.md).

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.

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

```

Thank you very much to both of you.

---

<div class="post-metadata">

**Author:** ![system](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/system/32/1_2.png) [@system](https://discourse.gohugo.io/u/system)\
**Post date:** [February 26, 2023, 5:29pm UTC](https://discourse.gohugo.io/t/error-when-using-the-tag-cache/43041/5 "2023-02-26T17:29:18Z")

</div>

Closed on February 26, 2023, 5:29pm UTC

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