How to use same layout for index.md - sub/index.md - sub/sub/index.md

Hi, given the following page structure, how can I get hugo to use the same layout for all index.md pages?

demo/
├── about
│   ├── index.md
│   └── team
│       └── index.md
├── blog
│   ├── post-1.md
│   └── post-2.md
└── index.md

i.e. only the blog section should use the layouts/_default/list.html and layouts/_default/single.html layouts but the index.md pages should all use the same “index layout”.

I tried with adding a template file layouts/_default/indexpage.html" and defining layout = "indexpage" in the front matter of the index.md files (following https://gohugo.io/templates/lookup-order/#examples-layout-lookup-for-regular-pages - Single page in "posts" section with layout set), but that doesn’t seem to work as intended: / and about/ and about/team/ sometimes show the right layout and content, but sometimes also show no content at all, because hugo seems to use the list template (and there’s nothing to list).

Am I missing something? What would be the right (idiomatic) approach?

Thanks

hugo v0.75.1 extended on macOS

It seems to work as intended when making the index pages list pages by adding a _, i.e.

demo/
├── about
│   ├── _index.md
│   └── team
│       └── _index.md
├── blog
│   ├── post-1.md
│   └── post-2.md
└── _index.md

check out the difference between a leaf bundle & a branch bundle.

basically, you can’t nest directories that have index.md.

I have a suspicion you might also be dealing with left-over files if you’re running hugo server and making changes to your .md content structure on the fly - which is why it sometimes might look like it’s working and sometimes not. because if you run this fresh you shouldn’t see ANYTHING for /team in this structure:

demo/
├── about
│   ├── index.md
│   └── team
│       └── index.md