(SOLVED) In taxonomy template, show the taxonomy key (e.g. "Tags" for taxonomy tags)

Hi,

I have created a template to display the list of posts associated with a taxonomy key (e.g. the list of posts associated with the tag “programming”, or belonging to the series “review” as I have added a series taxonomy to my website).

How can I display the taxonomy key in the template? (if I’m not wrong, in my case, “tags” and “series” are taxonomy keys). I would need it in order to use {{ i18n ... }} in order to display the words “tags” and “series” in different languages. I have searched in Hugo’s doc and on the internet, and I have tried to find the information with {{ printf "%#v" . }} but to no avail.

I know that I could bypass the problem by creating one template for tags (tag.html) and one for series but I’d rather not as almost everything would be the same inside the two templates.

Thanks

Depends on which template you are talking about. If you are talking about something like layout/_default/taxonomy.html, you can do the following:

{{$data := .Data}}
<p> To get the plural "tags": {{$data.Plural}}</p>
<p> To get the singular "tag": {{$data.Singular}}</p>
2 Likes

Awesome, I don’t know how I missed this. Thanks a lot!