1

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
user1548418
  • 457
  • 4
  • 14
  • You can also decide to use sections as taxonomies... – Mr. Hugo Dec 01 '22 at 12:26
  • SO is a programming Q&A platform and this question is not about programming. Questions about operating systems, their utilities, networking and hardware, are off topic here. [What topics can I ask about here?](https://stackoverflow.com/help/on-topic). Please delete this – Rob Dec 03 '22 at 10:52

1 Answers1

0

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/

Jeremie
  • 646
  • 8
  • 24
  • Thanks, but I find it a little obscure, and what if I want to make it a real multi-lingual site in the future? All in all, I ended up creating custom global taxonomies "blog-tags" and "guide-tags" (in config.json) and specifying permalinks for them to point to "/blog/tags" and "/guide/tags", respecively. Then I created "layouts/blog-tags/" and "layouts/guide-tags" directories, with "term.html" inside each. This did the job for me. – user1548418 Dec 03 '22 at 14:16