Front Matter in Taxonomy Templates

Say I have a taxonomy.html in the _default layouts, which shows a list using the following code:

 <section id="main">
                    <h1 id="title">{{ .Title }}</h1>
                    <p class="lead">
                    {{ range .Data.Pages }}

                    {{ .Render "summary"}}
                    {{ end }}

(the above works just fine)

It would seem that front matter does not pass to the Taxonomy templates, as I cannot set custom fields such as meta description, date, or anything else. Am I right in this thinking? Or am I missing something?

For example, adding the following to the category does nothing:

testparam: "this is a test"

when added to the taxonomy.html template:

{{ .Params.testparam }}

I tested that I was modifiying the correct taxonomy.html template, because normal text will render when added.

See this:
And this:

1 Like

Thanks for the links, but they don’t really deal with the issue. Sure, I can access Site level parameters (including custom ones specified in the config.toml), but any params in the front matter of the category are ignored.

Are you getting any errors when you run hugo server?

Also what type of front-matter do you use? Your example looks like YAML and I don’t think that you need the double quotes in your testparam

1 Like

I am getting absolutely no errors when running hugo server. I can replace the testparam with some text, and it will display just fine. Other variables such as:

{{ .Title }}
{{ $.Param "testparamss" }}
{{ }}

all display fine (the testparamss above is set in the config.toml)

I removed the quotes, but still not working. I am using Yaml (set in config.toml):

MetaDataFormat = "yaml"

Reading @bep 's comment in this thread Taxonomy Additional Information in Data it seems that you need to place your inside a directory structure that matches the tag URL.

So to solve this issue you need to create an identical _index.html under content/tags/my-tag/

I’m not quite sure if this a bug or a choice by design.

@Jonathan_Griffin If you want you may file a Github issue and see what the Devs have to say about this.

I have to admit though that replicating taxonomies’ URLs in folders is a bit of an overkill.

So if you open a Github issue post the link over here so that I can up-vote it or comment over there.

1 Like

Thanks @alexandros, and sorry if I wasn’t clear on this point, but that is exactly what I have done.

Also you referenced _index.html in your last reply, but presume you meant

But from @bep’s reply in the post you linked:

The new way since Hugo 0.18 is to put a content file named “” in
And put the metadata (title, params, content etc.) in there.

So it would seem, that this must be a bug as clearly it should be working.

Also, seeing your edit, I’ll probably put together a quick test site tomorrow duplicating the issue, and then can post the repo along with the issue on github.

Also, creating a file for each category is not an issue. There is certain information like meta description etc that should be unique to each one anyway. My main concern is not being able to set variables in the front matter.

Thanks for taking the time to look at this though. Much appreciated, and will update this thread once the issue has been posted, most likely tomorrow morning.

Nope. It is not a bug. I have reproduced this and what @bep said works.

You need to provide us with your list.html template to see how you call this parameter.

I have successfully called the (pardon the earlier .html) parameter from within the folder tree that corresponds to a given tag.

If you cannot do the same, then there is a problem in your template.

1 Like

@alexandros Well, if you have it working, then I must not have it correct.

I will create a more simple test site tomorrow to see if I can get it working. Then if I can, it will be on me to sort out my own code, or try and duplicate the error on the public repo that everyone can access.


1 Like

@alexandros A quick update. It looks like by changing the default category name, it broke things.

I don’t know as of yet, whether this is due to me not changing things correctly or a bug.

But with the category name (plural) kept as “categories”, everything is working again.

Hugo uses the Plural by default for taxonomies.

Look at the Docs if you want to customize it.

1 Like

Well, that didn’t fix the issue.

When there are no posts assigned to taxonomies (so a empty template shows), everything works and the params show up. As soon as I assign a post they dissappear.

I’ll take another look tomorrow. I will probably create a new site and test. If that works, I will slowly port over all the functionality and content testing as I go. Hopefully I will track down what is causing this.

If I find anything I will update this post.

This seems a bit bizarre. I tested with a proper set of posts with the same tag assigned. Everything worked like it should.

It may be a trivial syntax error in your YAML front matter or more likely something wrong in the way you call this parameter in your list.html

But you know I’m no good at predictions or chewing on laurel leaves and even though the Oracle of Delphi is not that far away from where I live I need to see the template for further help.

P.S. Make sure that you run the latest version of Hugo.

1 Like

I am not used to creating issues, so hopefully there is enough info. TBH, I think the repo will be the key here. I have absolutely stripped the site down to the very bare minimum:

Now you know what was wrong as @bep pointed out at the Github issue.

It was just a missing hyphen in your folder’s name.

1 Like

So for everyone else, this is what @bep said:

The path to the “” must match the normalized taxonomy path, i.e. what you see on the file system and in the browser:


So, not “siteground news”, but “siteground-news”.

Essentially, when creating my categories, I made the folder “siteground news”, when I should have made it “siteground-news”.

@alexandros Yeh, it’s amazing that something so simple caused me so much grief today. I am glad its all sorted now.

Thanks for your input on this.