Show a page of selected tag

Hello.

This might be a super dumb question, but, I can’t seem to be able to figure it out.

I just want to create my layout/_default/list.html in a way that it’ll show posts tagged only with a selected tag.

I’ve my hero partial that I display on all pages. It has a list of tags and when I click on any one of them, I should be taken to a tag page that’ll show the posts with that specific tag.

I’ve tried reading the documentation and a few forum posts, but, all I found it hard-coding the tab value in the range function, something like this: {{ range .Site.Taxonomies.tags.tagName }}. Even when I tried hard-coding the value, I didn’t get any post and also, hard-coding a page for each tab won’t be a possible solution for me.

Here’s the repository showing my current code: https://github.com/Hrishikesh-K/hugo-tags/

Your home page template (layouts/index.html) does this:

{{ range where .Site.RegularPages "Type" "in" .Site.Params.mainSections }}

That’s fine.

But the template used by all other list pages on your site (layouts/_default/list.html) does the same thing. Change it to:

{{ range .Pages }}

See:

1 Like

As expected, it was essentially simple.

And by sharing your repository, it was essentially simple to find the problem. Thank you.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.