range over all terms in a taxonomy with a template in
.Data.Terms gives me an empty slice/array
.Pages gives me the correct list of terms
- Why doesn’t
.Data.Terms work here?
- How do I get the number of entries for each term? The documentation mentions
.Count(term) but how would I use that in
range .Pages? Something like
.Count(term) always gives me an error because of an unexpected “(” in operand.
Edit: Figured out the last one: The parentheses are misleading, one should simply put the term after
Count. But the result of
site.Taxonomies.<taxonomie>.Count <term> is wrong
This part of the documentation is preciously short of examples.
As far as I know,
.Data.Terms is used to represent all the terms of a taxonomy, which can be accessed through
layouts/<taxonomy>/terms.html is at position 6 in the taxonomy list template lookup hierarchy, whereas
layouts/<taxonomy>/list.html is at position 8. Perhaps that makes a difference, leading to
.Data.Terms working in the first, but not in the second. But should it?
nil when rendering a term page; it is a map when rendering a taxonomy page.
With this layout structure…
│ ├── baseof.html
│ ├── home.html
│ ├── list.html
│ └── single.html
layouts/tags/list.html template is used to render both taxonomy and term pages.
I am unable to reproduce the problem you’re experiencing with “an empty slice”
git clone --single-branch -b hugo-forum-topic-45919 https://github.com/jmooring/hugo-testing hugo-forum-topic-45919
As I am now, too. If I were inclined to believe in magic, I’d think that it suffices for you to have a look at a problem for it to go away.