Issue with preserveTaxonomyNames and capitalization

Initially, I was using tags without using preserveTaxonomyNames. All my links worked fine but were all displaying as lowercase. I set preserveTaxonomyNames to true, which corrected the display but broke some of the linking.

Here is an example:
from my-article.md

tags = [“Linux”, “BSD”, “filesystems”]

… and the partial that displays the links using tags:
{{ range $name, $taxonomy := .Site.Taxonomies.tags }}
{{ $name }}
{{ end }}

With preserveTaxonomyNames off, they of course display all lower-case and all the links take you to the correct page. With it set to true, the link display is corrected but the names in the href attributes are all lowercase, despite the tags folders being the same as the display name.

When I render my site, my tags folder sub directories matches the case of the tag as defined in the .md file.

So, either I need to find a way to tell Hugo to make the tag sub directory names all lower case (to match what urlize outputs) or I need to not use urlize, so that the href attrib matches the directory name within tags/

Is there another solution aside from not piping to urlize?

Thanks

1 Like

I thought I should post a clarification since this got quite a few views and no replies. In short, it seems the problem is that, when preserveTaxonomyNames is set to true, the filesystem created also preserves where it should not.

With the settings off, everything is fine except for the display. Everything is all lower-case (filesystem directories, links, and the display text of href links. a link to tags/bsd points to folder tags/bsd and the link is “bsd” all lower-case.

With the setting on, you will have a href link display text of “BSD” with a working href to the filesystem directory tags/BSD.

The problem is, if you follow the documentation and urlize the name to be used in the href, it breaks the link. The href becomes tags/bsd but the folder is still tags/BSD.

Hope this helps make more sense of the issue. My solution is to simply not urlize. However, the correct action would seem to be that Hugo respects that I would likely urlize links to directories and make them all lowercase.

Has anyone else ran into this issue? What did you do as a workaround?

My workaround (with preserveTaxonomyNames set to true) is to simply not pipe to urlize because my tags directory was not “urlized” when it was created on the filesystem:

a href = “/tags/{{ $name }}”>{{ $name }}./a

Thanks

Ok, so it appears to be a reported bug:
https://discuss.gohugo.io/t/hugo-0-19-preservetaxonomynames-true-false/5640

I guess my real question now is, should I close this thread since the issue has already been reported as a bug? What is the preferred etiquette here?

Regards,