After finishing my first ever Hugo website a few weeks back, I was trying to restart it from scratch. This was because I could rewrite the entire code which is clean, optimised and well-commented as opposed to the mess I created while learning the basics of Hugo. While doing so, I landed on a problem. I’m unable to use .RelPermalink to link to taxonomy pages. I’m displaying the posts as cards and below each card, I’m placing links to the tags it’s categorized it. I’m doing it something like (in my layouts/index.html):
{{ range where .Site.RegularPages "Section" "projects" }}
<div> <!-- Card container -->
<!-- rest of the code -->
{{ range .Params.Tags }}
<a href = "{{ $.RelPermalink }}">
<p class = "tag tag-{{ . }}" uk-tooltip = "#{{ . }}">{{ . }}</p>
</a>
{{ end }}
</div> <!-- /Card container -->
{{ end }}
I’m expecting the link to be something like <example.com>/projects/tag/<tag name>/. So, I have set-up the config.toml like this:
[permalinks]
tags = "/projects/tag/:slug/"
However, when I run hugo server the links on the tags point to the home page. In the previous version of the website, I was using printf to get the link. That was something to get the job done. But, since I’m planning to keep the code clean, I don’t think using printf is a wise decision (or is it?).
Here’s my repo: https://github.com/Hrishikesh-K/Portfolio/tree/v2
Can someone please tell me if I can get .RelPermalink working here?