# How to create a taxonomy menu

**URL:** <https://discourse.gohugo.io/t/how-to-create-a-taxonomy-menu/10223>\
**Category:** support\
**Created:** [January 27, 2018, 12:53pm UTC](https://discourse.gohugo.io/t/how-to-create-a-taxonomy-menu/10223 "2018-01-27T12:53:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![lumbric](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/lumbric/32/5079_2.png) [@lumbric](https://discourse.gohugo.io/u/lumbric)\
**Post date:** [January 27, 2018, 12:53pm UTC](https://discourse.gohugo.io/t/how-to-create-a-taxonomy-menu/10223/1 "2018-01-27T12:53:44Z")

</div>

I have a site with many projects which are organized by year and category. I want to display these projects as taxonomy lists and two taxonomy menus on every page (one for selecting the year and on for the category).

I’ve the basic instructions to do this here:

> **[Taxonomy Variables](https://gohugo.io/variables/taxonomy/#use-site-taxonomies-outside-of-taxonomy-templates)**
>
> Taxonomy pages are of type \`Page\` and have all page-, site-, and list-level variables available to them. However, taxonomy terms templates have additional variables available to their templates.

This works almost as I need it, but $taxonomyname contains the urlized version of the category name. My categories are “My Category 1”, “My-Thing”, “Another term” and it outputs “my-category-1”, “my-thing”, “another-term”.

I’ve found two workarounds, see also [here](https://github.com/gohugoio/hugo/issues/1208) and [here](https://discourse.gohugo.io/t/a-menu-generated-from-a-taxonomy-or-sections/625/4):

The following produces “My Category 1”, “My Thing”, “Another Term”:

```
<ul>
  {{ range $key, $value := .Site.Taxonomies.category }}
  <li><a href="project/{{ $key }}">{{ replace $key "-" " "| title }}</a></li>
  {{ end }}
</ul>

```

This one generates “My category 1”, “My thing”, “Another term”:

```
<ul>
  {{ range $key, $value := .Site.Taxonomies.category }}
  <li><a href="project/{{ $key }}">{{ humanize $key }}</a></li>
  {{ end }}
</ul>

```

In both ways capitalization is not kept exactly and “-” cannot be used at all. This is fine for me, but I am wondering if I am missing something.

Slightly off topic, but still related: This snippet can be used to highlight the currently selected menu entry:

```
{ range $name, $taxonomy := .Site.Taxonomies.category }}
{{ $currentCategoryUrl := $name | printf "%s%s" "/category/" | printf "%s/" }}
{{if eq $.URL $currentCategoryUrl}}<b>{{ $name }}</b>
{{ else }}
{{ $name }}
{{end}}<br>
{{ end }

```

(Tested with versions 0.26 and 0.34.)

---

<div class="post-metadata">

**Author:** ![lumbric](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/lumbric/32/5079_2.png) [@lumbric](https://discourse.gohugo.io/u/lumbric)\
**Post date:** [January 27, 2018, 1:20pm UTC](https://discourse.gohugo.io/t/how-to-create-a-taxonomy-menu/10223/2 "2018-01-27T13:20:42Z")

</div>

Related discussion also here: [Cannot display tags taxonomy](https://discourse.gohugo.io/t/cannot-display-tags-taxonomy/2908/2)

---

<div class="post-metadata">

**Author:** ![Mikhail](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/mikhail/32/1138_2.png) [@Mikhail](https://discourse.gohugo.io/u/Mikhail)\
**Post date:** [January 27, 2018, 2:07pm UTC](https://discourse.gohugo.io/t/how-to-create-a-taxonomy-menu/10223/3 "2018-01-27T14:07:56Z")

</div>

> [@lumbric](#):
>
> In both ways capitalization is not kept

Try in config.yaml

```auto
pluralizeListTitles: false
preserveTaxonomyNames: true

```

---

<div class="post-metadata">

**Author:** ![lumbric](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/lumbric/32/5079_2.png) [@lumbric](https://discourse.gohugo.io/u/lumbric)\
**Post date:** [January 27, 2018, 2:28pm UTC](https://discourse.gohugo.io/t/how-to-create-a-taxonomy-menu/10223/4 "2018-01-27T14:28:13Z")

</div>

Oh great, thanks for the fast reply! This works and makes the workarounds obsolete.
