Taxonomies item with some chars leads wrong URL

When taxonomy items have number sign(#) and such, generated url’s are wrong or funny.

#: uri contain literal number sign(#). It shuold be %23
/ : uri and filename within subdir
?,>, <,… : removed from url and file name, therefore conflict multi items.

samples:

---
categories: [ "C#", "PL/1" ]
tags: [  "C", "C#", "PL/1", "C?", "C?!<>"]
---

This is a known issue:
https://github.com/gohugoio/hugo/issues/8232

But you can handle this yourself…

1) Use a sanitized string:

tags = ["c-sharp"]

2) Create a corresponding content file:

hugo new tags/c-sharp/_index.md

3) Set whatever title you want:

title = 'C#'

4) When displaying the terms on a page:

{{ with .GetTerms "tags" }}
  <p>Tags:
    {{ range . }}
      <a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a>
    {{ end }}
  </p>
{{ end }}
2 Likes