How to get a tags page?

Hello

The questions might be basic but I am really lost … The core part of the question is, in my layout folder, where do I have to put and how I have to name the html page to produce a page with a tag list ?

I wrote a set of articles, with tags in the article headers, something like:

---
title:
author:
tags:
    - tag1
    - tag2
---

I made a tags folder in my contents:

mySite/
    content/
        post/
            toto.md
            titi.md
        tags/
        ...

Thus if I well understand, tags is now a section of my hugo website.

In my config.tom I put:

[[menu.main]]
    name = "Tags"
    identifier = "tags"
    weight = 300
    url = "/tags/"

By doing this, I obtain a page with the list my tags and looking at the page I know that this page follow the post-list.html partials. I guess, this is because the folder is empty and because tags is a hugo specific name ? What I want to do is to change the layout of this page.

I look at the doc here https://gohugo.io/templates/taxonomy-templates/#example-list-tags-in-a-single-page-template and here https://gohugo.io/templates/single-page-templates/ but I did not succeed.
Actually, I don’t understand what is the name of that html file and in which folder I have to put it.

Thanks and sorry for maybe a basic question

1 Like

The template at /tags/ will be a list page, it lists the terms.

I always forget the template naming, but you want either layouts/_default/terms.html or layouts/_default/taxonomy.html (try them in that order, see if the template changes).

1 Like

Thank you. I have created a layouts/_default/terms.html template along with a content/tags/ folder with a _index.md file and it works.

Here is the result: https://gsalvatovallverdu.gitlab.io/tags/

This is my terms.html layout: https://gitlab.com/gsalvatovallverdu/gsalvatovallverdu.gitlab.io/-/blob/master/layouts/_default/terms.html

3 Likes

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