List all pages below subsection

I have a website with multiple sections and subsections.

Example: In the first section there are four subsections.


In each subsection there are more nested sections (folders with _index.html).

Example: In the first subsection there are six subpages.


On /section-1/subsection-1/subsubsection-1 I want to list all pages which are below this path.

I know how to list all pages below section 1…

{{ range where .Site.Pages "Section" "section-1" }}

{{ end }}

…but not those below /section-1/subsection-1/subsubsection-1.

1 Like

Based on this GitHub comment I found a very easy solution:


  {{ range .Sections }}
        <a href="{{.Permalink}}">{{.Title}}</a>
      {{ partial "lists/recursive.html" . }}
  {{ end }}


{{ $child_pages := union .Sections .Pages }}
{{ range $child_pages }}
  <li><a href="{{.Permalink}}">{{.Title}}</a></li>
  {{ partial "lists/recursive.html" . }}
{{ end }}

There is also a .RegularPagesRecursive method as of recently.

1 Like

I really like the idea behind the new method, but in my case ALL pages are sections (to make the section tree fully navigational). So it would be nice to have something like .SectionsRecursive.

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