Taxonomy templates

Hi there,

A probably easy to answer question to the use of Taxonomies.
For this taxonomy:

article = “articles”

I have created these taxonomy templates:
/layouts/_default/terms.html (Not used, testing backup)

It is rendered as I expected at:

Inside this folder I also find back unique folders for every term user, all containing one 0 byte HTML page:
/site/articles/news/index.html (0 bytes, ignoring the template)
/site/articles/weather/index.html (0 bytes, ignoring the template)

How can I control the contents of the pages generated for each term, should I use a second taxonomy template? What I hope to achieve is to list all the content items for one specific term.
Sorry if this is a simple question, I was not able to find an answer in the documentation.

Best regards, Jeroen

@Jeroen Is it that you’re trying to create a separate list view for each taxonomy term? If so, would it make more sense to treat this like a section instead? I think I’m being thrown by your use of “articles” as a taxonomy term, when “articles” usually refers to content. Taxonomies are usually tags, categories, authors, etc.

If you want to control the way each term list page renders, I can only imagine you’d have to use a series of different if/else statements, or start interpolating the name of the terms into your CSS classes. Can you give me more information about what you’re trying to do?

Hi @rdwatters,

Just found out my email-response to your answer never got published… Thank you for your reply!
Forgive my lack of understanding and possibly mixing of terminology. With ‘term’ I meant ‘key’. Yes, this is exactly what I am trying to achieve.

I think rendering a section would not resolve my problem.In the end any content item in any section can be associated with any Taxonomy. Correct?

Documentation mentions one template (eg. category.terms.html) can be created to publish one page for a Taxonomy. This template generates one HTML page AND a range of folders for all the ‘keys’ I have attached to the Taxonomy via content. The folders contain a black html (0 byte) page ready for me to link to. Unfortunately I have no clue how to control how those pages are generated.

Any idea if this is possible at all?

Documentation suggests with examples of links it should be possible to render pages for keys.

    <ul id="tags">
      {{ range .Params.tags }}
        <li><a href="tags/{{ . | urlize }}">{{ . }}</a> </li>
      {{ end }}

My taxonomy template renders “tags/” without issues, but white pages for each “tags/key”.

OK, finally found the answer…
The folder ‘taxonomy’ can contain two templates per taxonomy. The ‘taxonomy template’ I was looking for is actually a ‘list template’ placed in the taxonomy folder.

SINGULAR.terms.html (Renders at /PLURAL/)
SINGULAR.html (Renders at /PLURAL/TERM/)

This is totally counter-intuitive in my humble opinion…
Hope this helps someone else down the road.



@Jeroen sorry for not getting back to you on this, but it sounds like you figured this out. W/r/t the docs, it looks like you can find this information in both Templates > Content List Template and Taxonomies > Displaying/Templates/Ordering, no? Have you considered a pull request on the docs to improve clarity? I’d be interested to know your thoughts on a more intuitive approach to documenting this feature (not that I’m disagreeing with you). Cheers.

Don’t get me wrong I appreciate the care and effort that went into the documentation.

I guess while reading the documentation I have build up certain expectations on how the software behaves and what can be achieved with Taxonomies. Never considered contributing, and yet have to find out how to perform a pull request but I am happy to do my share.

We are happy to help you along with the PR. The Hugo gitter Dev channel is probably the best place to go if you have questions. There’s a guide on contributing on the readme.

Thanks Steve, I was able to submit a pull request through the documentation site’s link. Think it would make sence to require a specific name for Taxonomy List templates. If Taxonomy Terms template (Listing ‘Terms’) is ‘SINGULAR.terms.html’, then rendering of the actual Term pages (listing ‘Values’) can be done with ‘SINGULAR.values.html’. Just a thought…