Missing tags

Hi,

I thought creating a tag list is done in a few minutes, but right now I’m trying to find out why some tags are missing.

My code is:

{{ $count := 0 }}
<ul>
{{- range $name, $taxonomy := .Site.Taxonomies.tag }}
	<li>{{ $name }} ({{ .Count }})</li>
	{{ $count = add $count 1 }}
{{ end }}
</ul>
Number of tags: {{ $count }}

The code is placed in a shortcode and should display a list of the tags used on the site.

Output of the script is

Number of tags: 666

but when I look at the “public/tag” directory, I see 672 folders. Doing some manual comparison, I found that eg. “public/tag/w.a.s.p.” is indeed created as folder (and accessible from the browser), links to 4 pages but is missing in the list created by the code shown above.

Does anybody have a hint what’s going wrong?

You are running into this bug:
https://github.com/gohugoio/hugo/issues/10475

You can work around it…

content/posts/post-1.md

+++
title = 'Post 1'
tag = ['wasp']  # no periods
+++

Then create the term page:

hugo new tag/wasp/_index.md

content/tag/wasp/_index.md

+++
title = 'w.a.s.p.'
+++

Then use the term page .LinkTitle instead of the term name:

{{ $count := 0 }}
<ul>
  {{- range $name, $taxonomy := .Site.Taxonomies.tag }}
    <li>{{ .Page.LinkTitle}} ({{ .Count }})</li>
    {{ $count = add $count 1 }}
  {{ end }}
</ul>
Number of tags: {{ $count }}
1 Like

Thanks for pointing me to the issue, seems I can stop wondering what I’m doing wrong. :smiley:

Also thanks for the workaround, much appeciated!

1 Like

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