Multi-level taxonomy

It would be nice to have a multi-level taxonomy. For example.

config.yaml

taxonomies:
  category: "categories"
  person: "persons"
    annotator: "annotators"
    author: "authors"
    recipient: "recipients"

And if I have in the front matter authors: John Smith, John Smith will automatically be added to the list of the taxonomy person.

I know that this can be done by adding person: in the front matter, but the hierarchy would be more convenient.

1 Like

Up. Is this function, nobody cares?

I’ve been thinking of this feature, and how I would propose it. I called it, “mapping parameters to taxonomy terms”.

My use case was listing XMPP clients in a directly. XMPP has things called XEPs, and they can be fully supported, partial supported, or no support.

So I’d like to something like:

---
title: "email-killah"
xepsupport:
  - "123"
  - "456"
xeppartial:
  - "678"
xeps:
  - "123"
  - "456"
  - "678"
---

Ideally I could configure it so xepsupport and xeppartial are “mapped” to the xeps taxonomy. There are few other examples where this would be handy for me.

@Mikhail, is that similar enough to what you are talking about?

1 Like

What you are offering is working now, if you manually add xeps: in each article. I suggest that the list of xerp: be automatically formed if the xerp: is designated as the parent in the hierarchy in the config.yaml

Right. That was an example of how it looks now, but I’d like to only use the following frontmatter:

---
title: "email-killah"
xepsupport:
  - "123"
  - "456"
xeppartial:
  - "678"
---

This might be something different than what you are talking about, so I’ll make a new feature discussion for it. :slight_smile:

I have not used wordpress for a long time, but people wrote here that taxanomies there support the hierarchy. I did not invent this myself, this logic of the taxonomy is already used in cms.

I am a WordPress specialist, so I can speak to that. WordPress supports two kinds of taxonomies, and one has a hierarchy, but they are based on terms, not the taxonomies themselves.

Each term can have a single parent term. So in your example, you want John Smith to be a sub-term of authors, itself a term in this scenario.

person (taxonomy) > author (term), > John Smith (term)

Is that what you want?

Hugo supports taxonomies the way WordPress does by default, which is a “flat” taxonomy, meaning all terms have the same relationship with each other and the taxonomy.

person (taxnomy) > John Smith (term)

Yeah… your subject was accurate. A “multi-level taxonomy”, or hierarchal taxonomy. :slight_smile:

How would you handle setting sub-terms in TOML or JSON?

1 Like

For me, the main thing is that the term from a subsidiary taxonomy is automatically included in the parent taxonomy. Whether it will be reflected in the URL for me is not important, but ideally it is desirable to give the user the opportunity to choose: display the hierarchy in the URL or not.

taxonomies:
  category: "categories"
  person: "persons"
    annotator: "persons/annotators" -- hierarchy in the URL as option.
    author: "authors"
    recipient: "recipients"

I am not an expert in formats, but I don’t think TOML and YAML nest values the same way. Instead of nesting taxonomies in front matter, would it be easier to config one taxonomy as a nested inside another taxonomy, from the config? Presuming it is possible, of course! :slight_smile:

Terms with slashes have solved my issue with a three level geo-taxonomy (country/region/city). Please visit example-page and click on one of the regions to see it in action.

This works due to some extra taxonomy/templates.html, which extract the right levels.

Hope this could be of help to you.

1 Like

That’s pretty cool! But can you please share the source if possible (or a mini example version of this site)?

It took some days - well weeks exactly - to make this work. And today I sometimes wonder, what happened…

Bottom line is, that the country/region/city feature includes a substancial number of template- and sub-template files. And even more of the same in order to translate special scandinavian letters from urls. This forum is not the right place for al this stuff.

But the main idea is straight forward. You need separate taxonomy/tempates for each route/level - ex.:

  1. https://udvandrerne.dk/lande/frankrig/
  2. https://udvandrerne.dk/regioner/frankrig/aquitaine/
  3. https://udvandrerne.dk/byer/frankrig/aquitaine/landiras/

The routes being lande (countries), regioner (regions) and byer (cities).

Next step is to make all links refer to not the present level/route - but the next level/route.

Then it should work.

I have not read the entire thread, but to me the core of this is the definition of the hierarchy.

Given this definition:

taxonomies:
  category: "categories"
  person: "persons"
    annotator: "annotators"
    author: "authors"
    recipient: "recipients"

If you expand on the current Hugo model, you will get an implied hierarchy from the URLs, but not a navigational tree structure. You will get a terms list on each level, but will get the lead nodes only in the .Data.Pages. But that is probably good enough (at least an improvement of what we have).

I understood that using the union function in the template, I can create a common list of terms for the three taxonomies. But the terms URL will lead to different folders. In principle, Hugo allows me to do what I want, but not quite like in cms.

I am behind a few releases, so don’t completely grok “lead node”. Is what you are describing look like this:

authors:
  - Alice
  - Frank
annotators:
  - Bob
recipients:
  - Carol
  - Dan
  - Eve

I think what you are describing is that the following paths are created:

/persons/alice
/persons/bob
/persons/carol
/persons/dan
/persons/eve
/persons/frank

A page won’t be created for /persons/authors/alice, but you can still use implied hierarchy to range over a list of content where Alice was an author. Is that correct?

Also, sorry if this is stale; a cursory issue search didn’t find anything about this. :slight_smile:

Similar to what @JLKM did, I also got a geography-based hierarchy working (two levels, country and city), although I did it with only one taxonomy called “locations”:

Can see the rendered locations (as a nested list, and as markers on a map) at:

https://worldtrip.greenash.net.au/locations/

I gotta say, in my opinion this was much harder to do than it should have been!

You posted the same answer in another old topic earlier today.

The forum software displays a warning before bumping an old topic.

Please do not ignore it again. We discourage bumping old topics of several years ago.

Hugo is in constant development and several features may have changed in the meantime.
Also people who participated in those discussions may no longer be around.

Furthermore cross-posting in several topics is not allowed in this forum.

Also see the Forum FAQ