Create taxonomy like behavior without using taxonomies

When using Hugo taxonomies, the URL becomes /tags/ or/categories/. I know these can be renamed. I’m looking for similar functionality, but without the addition of the taxonomy to the URL.

I can achieve this as follows:

content
  products
  _index.md
  iphone.md
  macbook.md
  apple.md
  microsoft.md
  microsft-surface-pro.md

Inside apple.md and microsoft.md I add layout = "keywords". In the other markdown files, I use keywords to list if they are part of Apple and/or Microsoft.

Under layout/products I create keywords.html which is where I range through and list all products by their keywords. This structure creates /products/apple/ and /products/microsoft/.

Is there a better way of achieving the same result? With this structure it gets difficult to see under products what is an actual product, and what is a keyword page. I’ve tried to use nested sections, but it becomes more complicated, and I can’t get it to work. Suggestions?

You can also do this with permalinks. For example:

[permalinks]
  products = "/:section/:filename/"

You may have to replace products with keywords in the above, but I think the general idea is there.

1 Like