Special characters in tags

I’m having trouble getting tags with special characters to work. For example, I might have the following tags: development, f#. Now, I create urls for the tag as follows:

<a href='/tags/{{$t | urlize }}'>{{ $t }}</a>

This works for development, but not for F#. The link created has an href of f (and not f%23, or f#).

I see running hugo does generate public/tags/f#/ , but going to

all are failing with a 404, page not found.

Is there something I’m missing?

@ashic On road for work, but perhaps this will provide some insight:

https://hugodocs.info/content-management/taxonomies/#preserving-taxonomy-values

Thanks, but it doesn’t seem to have any effect. I’ve noticed that I can view the page at:

site.com/tags/f%23/

(note the trailing / ). However, with href={{$t | urlize }}, the href still spits out “/tags/f”. I’m guessing ‘#’ is being treated differently? I’m seeing the same behaviour with preserving taxonomy values set to true, or false.

Hmmm. Well, the hash has a special meaning in URLs :smile: Have you considered using “f sharp” as a tag instead?

In the end, I went with href=/tags/{{replace $t “#” “%23” | urlize }} . The special case for # solves the issue.

2 Likes