Mainroad
Mainroad copied to clipboard
Tag URL in single page does not match overridden permalink format
I'm migrating an existing website to Hugo and using this theme. Everything is going great, but I found what appears to be a bug in the generation of tag links in single pages.
To prevent dead links, I have customized my tag and category URLs:
[permalinks]
tags = '/tag/:title/'
categories = '/category/:title/'
Although category links are generated correctly, and tag links are generated correctly in the sidebar, links under individual posts are not generated according to the configuration.
I looked at the sources and it appears that the issue stems from the post_tags.html:
<a class="tags__link btn" href="{{ "tags/" | relLangURL }}{{ . | urlize }}/" rel="tag">
I'm not very familiar with the Hugo programming syntax, but it looks to me like the URL is built using the hard-coded tags path instead of using the permalink built by Hugo, which is apparently what is done for categories:
{{- with $.Site.GetPage (printf "/%s/%s" $taxo $path) }}
{{- if gt $index 0 }}, {{ end -}}
<a class="meta__link" href="{{ .RelPermalink }}" rel="category">{{ .Title }}</a>
{{- end }}
I'll try to fix this by basing myself on the category code and submit a PR as soon as I can.
...it looks to me like the URL is built using the hard-coded tags path instead of using the permalink built by Hugo, which is apparently what is done for categories
I think there was a reason for that. 🤔
Sorry, my head is full of other things and I have no time to check it now, but If you plan to do PR, please read the contributing guidelines and test everything carefully.
To prevent dead links, I have customized my tag and category URLs:
Not sure if this changes the /tags/ page itself.