Hugo

Taxonomy Labels as Links

This seems to be such a basic thing that I haven’t found anyone else asking about it, but I just can’t seem to figure it out.

Here is the entirety of my single.html code:

{{ define "main" }}
{{ .Params.author }} | {{ dateFormat "January 2, 2006" .Date }}<br>

{{ .Params.categories }}, {{ .Params.tags }}

<h1>{{ .Title }}</h1><br>

{{ .Content }}

{{end}}

What I want is for the {{ .Params.categories }} and {{ .Params.tags }} to render as clickable links to their respective taxonomy lists, but I can’t figure out the language to make it pull the URLs.

Please help, or let me know what other information you need. Thank you.

Check the single page template example, specifically:

    {{ with .Params.tags }}
    <ul id="tags">
      {{ range . }}
        <li> <a href="{{ "tags" | absURL }}{{ . | urlize }}">{{ . }}</a> </li>
      {{ end }}
    </ul>
    {{ end }}

Also, here are some hints for sharing code in the forums. :slight_smile:

Thank you, I’ll do better next time. So now the trouble is this: if I try to use {{ range . }}, I just wind up with a “404 page not found”. Any idea why that would be happening?

I’d have to clone and run it myself, to troubleshoot it. You can check your logs, and run -v I think it is for verbose logs.

If you want others to take a stab at it, share your site source online, so we can just run hugo locally and check it. :slight_smile: