List pages in sub-section

I would like to be able to list all the pages of the parent sub-section on a single layout

Here is the structure of our guides:


So when I am on the /guide/performance/optimize-css/ page, how can I get a list of all the pages within the /guide/performance/ sub-section?

The HUGO docs don’t detail how to get only a sub-section.

Here is what I have tried:
I am able to get the full tree of the top-most section — /guide/ — by doing this:

{{ range where .Site.Pages "Section" "guide" }}
    <li><a href="{{ .Permalink | relURL }}" title="{{ .Title }}">{{ .Title }}</a></li>
{{ end }}

or this:

{{ range where .Site.Pages "Section" .Section }}
    <li><a href="{{ .Permalink | relURL }}" title="{{ .Title }}">{{ .Title }}</a></li>
{{ end }}

But I would assume that I’d be able to use .Parent to define which section I want to range through,

{{ range where .Site.Pages "Section" .Parent }}

Or at least put in a string:

{{ range where .Site.Pages "Section" "guide/performance" }}

Here you go, this is what I am using here:

{{range (.Paginate ( where .Data.Pages "Type" "stories")  9).Pages}}
	{{ .Render "summary"}}
{{ end }}
1 Like

Oh I get it. Thanks @brunoamaral :tada:
You have to range through pages with a consistent bit of front-matter, like type.

I just added guide: performance to all the /guide/performance/ sub-pages, and now I am ranging through them with:

{{ range where .Site.Pages "" }}
    <li class=""><a href="{{ .Permalink | relURL }}" title="{{ .Title }}">{{ .Title }}</a></li>
{{ end }}

Thanks for the assist!

1 Like

In my case I just have everything under stories

   |_ post 1
   |_ post 2