HUGO

How do I create multiple taxonomy lists?

Hey!

Within my site, I utilize the two default taxonomies for the blog. I have designed a list page to display these taxonomies, so when a user clicks a category, they see a list of posts relating to that category, and it works well.

I am creating a new section - integrations - where I want to list the software which our platform integrates with. I want to break these integrations down into categories. I then want to display the results for each of the categories in a list, like the blog above. But, I want to design the integrations list differently. How do I create two taxonomy list pages?

Also, currently, the taxonomy category pages reside on a URL like website.com/category. Is it possible to have: website.com/blog/category and website.com/integrations/category?

Thanks
Joe

Your are currently assigning one or more categories to your “blog” pages.

You want to assign one or more categories to your “integration” pages.

Will the two content types share a particular category? For example, would you assign the category “foo” to both a “blog” page and an “integration” page?

1 Like

I can keep them separate.

So how about using a different taxonomy for your integration pages?

config.toml

[taxonomies]
  category = "categories"
  tag = "tags"
  type = "types"

Then create unique layouts as needed…

Taxonomy List of terms List of pages with a particular term
categories layouts/category/taxonomy.html layouts/category/term.html
tags layouts/tag/taxonomy.html layouts/tag/term.html
types layouts/type/taxonomy.html layouts/type/term.html

See https://gohugo.io/templates/lookup-order/

Thank you for your feedback. This seems like a great solution and it answers my query re the multiple taxonomies. I will try this tonight. Once again, thank you

You also asked about changing the URL of taxonomy and term pages.

If you want the list of categories to appear at /blog/categories:

  1. Create a new page:

    hugo new categories/_index.md
    
  2. Edit the new page:

    title = "Categories"
    date = 2020-11-28T13:24:19-05:00
    draft = false
    url = "/blog/categories"
    

If you want the list of pages with the category “foo” to appear at /blog/category/foo, add a permalinks section to your site configuration file.

[permalinks]
categories = "/blog/category/:slug"