Simple but challenging list template

How would I go about making list templates that only show a list of the bundles at the level immediately below? This seems to be surprisingly tricky - at least for my limited abilities.

IOW if I have such a structure as shown below, the home page should only show the branch bundles (sections) chairs and tables. Chairs would only show dining-chair, footstool and lounge-chair. Only when I’m in lounge-chair should I see the articles (leaf bundles) drilling-holes, sawing-wood, etc.

I’m thinking this is a pretty common site structure for project descriptions or documentation but I can’t seem to find any examples in the documentation that describe this sort of arrangement … or am I just blind?

content
  ├── _index.md
  ├── chairs
  │   ├── _index.md
  │   ├── dining-chair
  │   │   ├── _index.md
  │   │   ├── steaming-beech
  │   │   │   ├── img3.jpg
  │   │   │   └── index.md
  │   │   └── using-a-spokeshave
  │   │       └── index.md
  │   ├── footstool
  │   │   ├── _index.md
  │   │   ├── dovetail-joints
  │   │   │   └── index.md
  │   │   └── planing-oak
  │   │       └── index.md
  │   └── lounge-chair
  │       ├── _index.md
  │       ├── drilling-holes
  │       │   └── index.md
  │       ├── sawing-wood
  │       │   └── index.md
  │       └── shaping-the-legs
  │           └── index.md
  └── tables
      ├── _index.md
      └── coffee-table
          └── _index.md

Test this:

{{ $all := where .Site.Pages "Parent.RelPermalink" "eq" $.RelPermalink }}
{{ range $all }}
     {{ .Render "li" }}
{{ end }}

If there are error messages, then try to limit the list of sections.

{{ $all := where (where .Site.Pages "Section" "in" (slice "tables" "chairs")) "Parent.RelPermalink" "eq" $.RelPermalink }}

Ah, clever! Thanks. The second version works with the sections specified in a slice. Which is what I was really trying to avoid (of course!). Would this work if there were more levels, say metal-dining-chairs, wooden-dining-chairs or plastic-dining-chairs?

It would be nice if something like the first version worked (it does throw a memory error) at any level of nesting without having to specify the section names in the template.

But for now this is a huge help. Thanks again.

As I understand it, the variable .Parent has a value only for pages that have up level _index.md. If all the above folders have an _index.md, then it should work for all levels.

Yes, you’re right. It works at the next level too.