I have `/category/[topic]/’ page with a list of articles for that given page.
Now, I would like to add more content there - perhaps some descriptions, images etc.
Each category page would have quite different content and maybe even structure so likely I cant just go with one template, instead, I would prefer to have an ‘[category].md’ file with the content that I could feed into generation of the category pages for given topic. If there is no custom category content, then Hugo would just generate the page without it as usually.
How can I achieve it?
I’m not sure I understood correctly so correct me if I’m wrong.
Before anything else, so we are on the same page: /category/[topic]/
= /taxonomy/term/
I don’t think you can create a taxonomy.md
file to change a taxonomy. What you can do is create an _index.md
file per term in /content/
and create a separate folder per taxonomy in /layouts/
. Here’s an example:
-
In your /content/
folder, create a folder for each of your term with an _index.md
file in each. It should look like this:
/content/categories/cat1/_index.md
/content/categories/cat2/_index.md
/content/tags/tag1/_index.md
/content/tags/tag2/_index.md
/content/series/abd/_index.md
-
In your /layouts/
folder, create a folder for each of your taxonomy with a terms.html
file each. It should look like this:
/layouts/categories/terms.html
/layouts/tags/terms.html
/layouts/series/terms.html
This is where you should place all the code related to the design layout when the terms are displayed and use those frontmatter params defined in your _index.md
files.
(There is probably a better way of doing the above.)
If you are asking if you can have a different design/layout for each term
like so:
-
example.com/categories/cat1/
= different design
-
example.com/categories/cat2/
= different design
-
example.com/tags/tag1/
= different design
-
example.com/tags/tag2/
= different design
I’m not sure if it is possible, I have not encountered it and I haven’t tried it either.
To summarize:
-
/content/taxonomy/_index.md
is where you add frontmatter params.
-
/layouts/taxonomy/terms.html
is where you code the design and use those params.
Hope it helps. Shalom!
1 Like