How to create a taxonomy menu

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:

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 and here:

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.)

Related discussion also here: Cannot display tags taxonomy

Try in config.yaml

pluralizeListTitles:        false
preserveTaxonomyNames:      true

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