Mainroad icon indicating copy to clipboard operation
Mainroad copied to clipboard

Tag URL in single page does not match overridden permalink format

Open madd0 opened this issue 2 years ago • 2 comments

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 }}

madd0 avatar Apr 17 '23 14:04 madd0

I'll try to fix this by basing myself on the category code and submit a PR as soon as I can.

madd0 avatar Apr 17 '23 15:04 madd0

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

Vimux avatar Apr 18 '23 17:04 Vimux