Arbitrary-depth hierarchies

Newbie question.

Hugo appears to encourage a three-level layout:

  • front page
  • first layer down, assumed to be lists of things, rendered by list.html
  • second layer down, assumped to be individual items, rendered by single.html

What if my hierarchy is more complex/varied than that? E.g.

  • / (front page)
  • /about/ (and no pages below)
  • /product/family/item/color/ (individual item)
  • /product/family/item/ (list)
  • /product/family/ (list)
  • /product/ (list)

How can I map those to list.html vs single.html? I was thinking I could simply specify whether I wanted something to be treated as a list, or as an item, by adding “type: single” or such to the front matter of the various, but I’m not succeeding (but maybe I am doing it wrong).

Is there an example somewhere that would show how to do this, assuming it can be done?

Going off your example, keeping same order, try:
1 Like

Are you saying that if I name it index.html, Hugo will use single.html, and if I name it _index.html, Hugo will use list.html? If so, as conventions go, this one is … non-obvious.

On the Page Bundles you can read about leaf vs branch bundles.


Well, it’s obvious if you read the docs as @frjo mentioned.

Obvious is in the eye of the beholder :wink: For example the About page in the example on uses an although it has no children. While I understand now this is legal, it’s also somewhat misleading as there is no list of anything.

At least I think so. Again, newbie here.

Thanks for your help.

That may be a mistake, and an easy one for you to contribute a fix by creating an issue seeking clarification and then correcting it (as it is just removing an underscore). :slight_smile:

The page in question:

PR submitted :slight_smile:

1 Like