How to Specify Category Slug?

Hey guys,

I’m migrating my website to Hugo. My existing category name is Information Security, but the url slug is infosec. Is there any way to achieve the same with Hugo?


Not sure what your definition of “category” is – but I guess it maps into Hugo’s taxononomies.

And what you want is possible in the upcoming Hugo 0.18 release that is released, drum roll … TODAY.

With that you can define taxonomies (categories, tags etc.) and define frontmatter, with title (i.e. “Information Security”) and content etc.


Clearly, this is the best support channel ever – a new version of the software right after a request from a random dude.

@bep any chance you could point to a specific section in the documentation? Otherwise, github commit would be as useful.

We just released it so the docs at is updated. A relevant search term could be “”.

1 Like

@bep the 0.18 release looks awesome. Thank you. By using the front matter for taxonomies, is there any way to access it from the taxonomy terms template?

Yes, that is one of the main points about it. Just do {{ .Title }} etc. inside the templates.

@bep not sure we are on the same page, except I’m missing something.

I have

        category.terms.html contains title: Information Security.
category.terms.html contains

    {{ range $key, $value := .Data.Terms }}
      <li><a href="#">{{ $key }}</a></li>
    {{ end }}

In this case $key is infosec, which is correct. It doesn’t look like I can access .Title of infosec/ from inside of the range – this results to an error:

ERROR: 2016/12/22 08:59:08 general.go:236: Error while rendering page : template: taxonomy/category.terms.html:9:25: executing "taxonomy/…

You leave me guessing a little with those half-pasted errors … but the key/value you get in that range is a list of terms / wegithed page list pairs.

So, pseudo code, not tested:

 {{ range $key, $value := .Data.Terms }}
      <li><a href="#">{{ $key }}</a></li>
     {{ range $value }}
    {{ .Weight }}:  {{ .Page.Title }}
    {{ end }}
    {{ end }}

Or something like that.

Sorry. You are accessing the front matter of a post that belongs to a term. But what I’m curious about is accessing the front matter of a specific term from the category.terms.html template.

As an example, see this page:
It has an open-source taxonomy (that is capitalized with css). I’m trying to map it to Open Source string. In my case, I have an infosec taxonomy that I want to output as Information Security on the terms list page (/categories) specifically.

P.S. It’s all good if I go to a term page (/categories/infosec/). I can access front matter from there.

Sorry if I sound confusing.

Well, that was the template you showed me, so I assumed that was the problem area.

I suspect that you have a “context issue” – i.e. you try to do a .Title inside the range. Try $.Title. But, I’m guessing a little, as your example missed a piece or two.

Yes, that is exactly what I’m trying to achieve here. Unfortunately, it still doesn’t work as expected.

url: http://localhost:1313/categories/
code (taxonomy/category.terms.html):

    {{ range $key, $value := .Data.Terms }}
      <li><a href="#">{{ $.Title }}</a></li>
    {{ end }}



expected output:

Information Security

Just to clear up something, the $ variable references the initial context of the current template. That is why $.Title doesn’t change. It’s handy when you want to reference the current page (or whatever) from inside a loop in a given template (since the . context changes within loops).

@moorereason understood. Thank you. Giving this page as an example, is there any way to map taxonomy term to a custom string and show this whole list of taxonomies based on custom values? Something like:

Development → Web Developemnt
MongoDB → MongoDB Database
Pesonal → Personal Posts


@andreyg, you’re blazing a trail on new Hugo features!

See Content for home page and other list pages at the end of I think you want to create content/categories/infosec/ with a title defined in the front-matter.

That’s exactly what I have. I feel like {{ range .Data.Terms }} does not understand the context.

OK, I think I understand.

In Hugo there are

  • Taxonomy terms
  • Taxonomy lists

Both can have a template and content file(s).

So, for the categories example:

/content/categories/ // <= terms
/content/categories/infosec/ // <= list

The template you are editing is the taxonomy terms template. You have no content file for the categories terms, so you get the default (“Categories”).

What you (probably) want to do is to update your list template or whatever template is used to render your taxonomy lists.

But you can also test out the theory by putting an file into the /categories folder and see what happens.

@bep correct. I use


to render all taxonomy terms. (In my previous example I showed it as /layouts/taxonomy/category.terms.html which is the same as /layouts/_defaults/terms.html according to

Alright, the only way I found to achieve what I want is by using .Site.Pages.

    {{ range where .Site.Pages "Type" "categories" }}
      <li>{{ .Title }}</li>
    {{ end }}

.Data.Terms simply doesn’t know anything about

I believe you can also use .Data.Pages (which should give you the pages that is relevant, and more portable)

Nope. .Data.Pages is empty.