# List all pages below subsection

**URL:** <https://discourse.gohugo.io/t/list-all-pages-below-subsection/27418>\
**Category:** Uncategorized\
**Created:** [August 7, 2020, 4:45pm UTC](https://discourse.gohugo.io/t/list-all-pages-below-subsection/27418 "2020-08-07T16:45:08Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Troy](https://avatars.discourse-cdn.com/v4/letter/t/85f322/32.png) [@Troy](https://discourse.gohugo.io/u/Troy)\
**Post date:** [August 7, 2020, 4:45pm UTC](https://discourse.gohugo.io/t/list-all-pages-below-subsection/27418/1 "2020-08-07T16:45:08Z")

</div>

I have a website with multiple sections and subsections.

Example: In the first section there are four subsections.

```
/section-1/subsection-1
/section-1/subsection-2
/section-1/subsection-3
/section-1/subsection-4

```

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

Example: In the first subsection there are six subpages.

```
/section-1/subsection-1/subsubsection-1
/section-1/subsection-1/subsubsection-1/example-1
/section-1/subsection-1/subsubsection-1/example-2
/section-1/subsection-1/subsubsection-2
/section-1/subsection-1/subsubsection-3
/section-1/subsection-1/subsubsection-4

```

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`.

---

<div class="post-metadata">

**Author:** ![Troy](https://avatars.discourse-cdn.com/v4/letter/t/85f322/32.png) [@Troy](https://discourse.gohugo.io/u/Troy)\
**Post date:** [August 7, 2020, 6:31pm UTC](https://discourse.gohugo.io/t/list-all-pages-below-subsection/27418/2 "2020-08-07T18:31:44Z")

</div>

Based on this [GitHub comment](https://github.com/gohugoio/hugo/issues/465#issuecomment-476906202) I found a very easy solution:

list.html

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

```

partials/lists/recursive.html

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

---

<div class="post-metadata">

**Author:** ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)\
**Post date:** [August 7, 2020, 6:54pm UTC](https://discourse.gohugo.io/t/list-all-pages-below-subsection/27418/3 "2020-08-07T18:54:27Z")

</div>

There is also a `.RegularPagesRecursive` method as of recently.

---

<div class="post-metadata">

**Author:** ![Troy](https://avatars.discourse-cdn.com/v4/letter/t/85f322/32.png) [@Troy](https://discourse.gohugo.io/u/Troy)\
**Post date:** [August 8, 2020, 12:34pm UTC](https://discourse.gohugo.io/t/list-all-pages-below-subsection/27418/4 "2020-08-08T12:34:39Z")

</div>

I really like the idea behind the new method, but in my case ALL pages are sections ([to make the section tree fully navigational](https://gohugo.io/content-management/sections/#nested-sections)). So it would be nice to have something like `.SectionsRecursive`.

---

<div class="post-metadata">

**Author:** ![system](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/system/32/1_2.png) [@system](https://discourse.gohugo.io/u/system)\
**Post date:** [August 10, 2020, 12:34pm UTC](https://discourse.gohugo.io/t/list-all-pages-below-subsection/27418/5 "2020-08-10T12:34:44Z")

</div>

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