It appears the Terms map is empty, despite having plenty of tags on my site. When I make a list of .Pages, I get a list of pages for each tag, as I expect. I’ve also noticed the same behavior if I put this template at layouts/_default/terms.html. Am I doing something wrong here?
Side note: I’ve also noticed that .Title doesn’t output anything in this template. Is that expected? I’ve been using {{ .Data.Plural | title }} to get my page title.
Thanks. No reason why I couldn’t use .Pages. Most of the examples in the docs show templates iterating over .Data.Terms. If that’s not the correct guidance for terms templates, it’d be great if the docs could be updated to clarify that point.
There is one example of iterating over .Pages but the title of that bit is “Displaying custom metadata in Taxonomy Terms Templates” which didn’t seem to be what I was looking for.
I also thought it was odd that .Title wasn’t working correctly, since again several of the examples in the docs use it for the page title, and all my other templates use it. Thought that might be a configuration issue in my site, or possibly a bug?
Got a chance to try this, but it doesn’t work. I’m iterating .Pages to produce a list of tags, but .Title is empty. .Page.Title is also empty.
Here’s my template:
{{ define "main" }}
<header class="page">
<h1>{{ .Data.Plural | title }}</h1>
</header>
<h2>Pages</h2>
<ul>
{{- range .Pages -}}
<li><a href="{{ .RelPermalink }}">{{ .Title }}</a></li>
{{- end -}}
</ul>
<h2>Terms</h2>
<pre>{{ jsonify (dict "indent" " ") .Data.Terms }}</pre>
<ul>
{{- range $term, $page := .Data.Terms.Alphabetical -}}
<li>{{ $term }} -- {{ $page }}</li>
{{- end -}}
</ul>
{{ end }}
Iterating .Pages gets me links, just like any list template, but I’m missing all the useful metadata about tags. Is there a way to get at term weights, counts, etc by iterating pages?
Well, that’s weird! What version of Hugo are you using? Could it be something to do with how I’m running my dev server? I usually run ./dev-server.sh, which does this: