Using different list template by depth

I have the following content structure, i would like to use different list templates for and Any suggestions will be appreciated.

    stories/ <- template A
          18273-story-1/ <- template B

[Not tested]

Apply template B to all the stories section lists: stories/list.html.

The template A only for the stories list page: stories/index.html (or layout: call in the frontmatter).

Edit: The @bep solution is better than mine :wink:

I think the currently simplest solution is to set either type (recommended) or layout with cascade; you should be able to match the levels with a Glob:

type = "b-type"
path = "/stories/*/**"

Note that cascade can be set both in front matter and in site config.


I think Hugo’s TOML parser supports “dot syntax”, so the above could probably be made into:

type = "b-type"
_target.path = "/stories/*/**"

Which is easier to read.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.