HUGO

Add category pages

Hello, I’ve a question for you.

I’ve managed to deploy my website and everything work fine. Though I would like to add pages with all the articles related to a specific category.

As far as I can tell, the theme I use does support categories: I can add them in the articles and there’s a folder in /public named /categories where there are the categories I made, i.e. “Music”. Inside it there’s a .xml file named “index.xml” that contains all the articles.

The thing, anyway, is that there’s no page in the website where this list is: there’s no “music” page with all the articles of that particular category, basically.

What should I do to implement those category pages?

Here’s the GitHub page, so that you can take a look: GitHub - protofrancesco/protofra.me

Thanks!

HI,

in CONFIG, you should activate taxonomies and set permalinks for it

[taxonomies]
    category            = "categories "

[permalinks]
    categories =  "/:section/:slug"

you have to create taxonomy list pages, if you don’t like the default

Read the warnings generated when building the site. In addition to telling you what is wrong, they also tell you what needs to be done.

WARN 2021/03/05 07:30:27 found no layout file for "HTML" for kind "taxonomy": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.
WARN 2021/03/05 07:30:27 found no layout file for "HTML" for kind "term": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.

The theme you have chosen doesn’t contain any _default templates, it does not leverage a base template, and it hasn’t been updated in almost two years.

Regardless of whether you choose to fix what you have or use a different theme, there is no need to include a [taxonomies] or [permalinks] section in your config.toml file; the default configuration already supports both “categories” and “tags”. See https://gohugo.io/content-management/taxonomies#default-taxonomies.

look in

you find Layout Lookup for Taxonomy Pages and Layout Lookup for Term Pages

I use: layouts/category/taxonomy.html and layouts/categories/term.html to get the difference!