Display list of nested sections

I have a layout like this:

content/posts
  _index.md  
  cats/
    _index.md
    test.md
  shapeless/
    _index.md
    test.md

I would like to display the “cats” and “shapeless” summary on the “posts” page but I don’t see anything. If I add a file directly below posts i.e content/posts/test.md the summary appears on the posts page.

Have i missed something? thanks!

Hey,

There are several ways to get what you want, but I would just flatten the section tree from the section you’re in:

{{ template "list-section" . }}

{{ define "list-section" }}
{{ range .Pages }}
{{ .IsPage }}
* {{ .Title }}
{{ end }}
{{ template "list-section" . }}
{{ end }}
{{ end }}

You can drop the IsPage conditional if you also want to list the section headers.

Note that for Hugo < 0.57 the syntax is slightly different (it was simplified).

Thanks! I have a nice solution now :slight_smile: