Setting up layouts for nested section and its pages

This is not a duplicate of: Setting a custom single layout for nested section (or any other similar issue I could find)

Reproduction: GitHub - Hrishikesh-K/hugo-43833


For all content pages in the “work” section, I wish to have a base layout and then each page would separately have its specific content on it. So I want the inheriting something like:

  - layouts/work/single-baseof.html
    - layouts/work/work-1-1.html

That’s how I thought it would work when I read base template for single pages, but for some reason, I seem to have it wrong.

Result I’m getting:

A 404 when I visit /work/work-1/work-1-1/.

Alternatives considered:

I could add conditional logic to layouts/_default/baseof.html to add the “common” stuff there, but would like to avoid it if possible.

Additional notes:

The problem doesn’t occur if I remove single-baseof.html and directly use work-1-1.html to inherit baseof.html.

What am I missing, or how can I achieve the above scenario?

A baseof template is at the top of the stack, regardless of where you have placed it. The next template down will be a section (list) or page (single). Or to put it another way, a baseof template cannot be called by another baseof template.

Oh, I saw Layout lookup rules and by seeing a specific baseof (in this case single-baseof), I thought I could use it to extend. It’s probably a good suggestion to add that note to the docs.

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