Hugo - multiple sections of website with their own local taxonomies?

221 views Asked by At

I'm building a website that has "blog" section and and "guide" section, like this:

mywebsite.com/blog/

mywebsite.com/guide/

Both blog and guide contain their own multiple posts. I'd like to add independent tags (taxonomies) to both blog and guide, so that I could list posts by specific tags, for example:

mywebsite.com/blog/tags/some_blog_tag

mywebsite.com/guide/tags/some_guide_tag

What should be my project's folder and file structure - both content folder and layouts folder - to implement this? It seems that hugo is built around the idea that the taxonomy should be global for the entire website. However, there are also "page bundles" in hugo. Can hugo define local taxonomies inside page bundles? I find the docs very confusing on this topic.

Also, what should be added to the config.json file to create such section local taxonomies?

I tried the following folder structure, but I get "page not found" when I access mywebsite.com/blog/tags/some_blog_tag or mywebsite.com/guide/tags/some_guide_tag

- content
  - blog
      _index.md
      blog_content1.md
      blog_content2.md
      blog_content3.md
  - guide
      _index.md
      guide_content1.md
      guide_content2.md
      guide_content3.md
- layouts
  - blog
      list.html
      taxonomy.html
  - guide
      list.html
      taxonomy.html
1

There are 1 answers

1
Jeremie On

One way to achieve that would be to use a multilingual site, with three languages:

  • one language named en (default)
  • one language named blog
  • the last one named guide

and adding the parameter defaultContentLanguageInSubdir: false

By doing so, you can host all your non blog/guide pages in the en language, and each blog/guide pages will have their own taxonomy as required.

See documentation for more information https://gohugo.io/content-management/multilingual/