How to check top-most section cleanly?

I have a fairly simple sections structure, according to docs (assume I have the same articles and products):

So my layouts/<type>/section.html is used to render every single section page of that type. My <type> shall be named special.

Trouble is, I want the top-most section rendered differently than the sub-sections - which will be rendered all alike, in fact they will share the same template as a leaf page.

I only mention the above if anyone has a cleaner proposition than what I currently have:

A test in section.html which decides whether this is the top-most section or not and goes for a partial, but I cannot get this work universally:

  • testing for .Ancestors or .Parent does not seem to work here; and
  • testing for .File.Path does work, but it is not universal (I have to check for articles and products, not for type), i.e. I cannot use it with type: special later on.

As I would like to re-use this setup, I really would like something more robust than checking for .File.Path. Is it possible?

Thanks a lot for any help in advance.

I would cascade the layout front matter field to descendent sections.

content
content/
├── articles/
│   ├── _index.md
│   ├── article-1.md
│   └── article-2.md
├── products/
│   ├── product-1/
│   │   ├── benefits/
│   │   │   ├── _index.md
│   │   │   ├── benefit-1.md
│   │   │   └── benefit-2.md
│   │   ├── features/
│   │   │   ├── _index.md
│   │   │   ├── feature-1.md
│   │   │   └── feature-2.md
│   │   └── _index.md
│   ├── product-2/
│   │   ├── benefits/
│   │   │   ├── _index.md
│   │   │   ├── benefit-1.md
│   │   │   └── benefit-2.md
│   │   ├── features/
│   │   │   ├── _index.md
│   │   │   ├── feature-3.md
│   │   │   └── feature-4.md
│   │   └── _index.md
│   └── _index.md
└── _index.md

templates
layouts/
├── articles/
│   └── section.html
├── products/
│   ├── descendent-section.html
│   └── section.html
├── baseof.html
├── home.html
├── page.html
├── section.html
├── taxonomy.html
└── term.html

site config
[[cascade]]
layout = 'descendent-section'
[cascade.target]
path = '{/products/**}'
kind = 'section'

Example:

git clone --single-branch -b hugo-forum-topic-56053 https://github.com/jmooring/hugo-testing hugo-forum-topic-56053
cd hugo-forum-topic-56053
hugo server

with that I could imagine - requires v0.146+

templates
\layouts
│   all.html        <- everything else (handles subsections and pages)
│   baseof.html     <- skeleton
│   home.html
│   special.html    <- root sections
│   taxonomy.html
│   term.html
hugo.toml
[[cascade]]
layout = 'special'
[cascade.target]
path = '{/*}'
kind = 'section'