Help with mainSections

I am using mainSections to generate the list page of posts for my blog located in the content/posts directory.

It’s picking up the posts correctly but also generating a root “Posts” page as well. This happens when there is and isn’t present in content/posts. Here is my code. Sure it’s pretty straightforward but any help is greatly appreciated.

 {{ $paginator := .Paginate (where .Site.Pages "Section" "in" .Site.Params.mainSections) }}
    {{ range $paginator.Pages }}
    {{ .Render "summary" }}
    {{ end }}
{{ end }}

I think you should try changing the above to .Pages

Perfect. Thanks @alexandros!

If you want to query all the site pages in the main sections, you could use .Site.RegularPages. .Pages is contextual and means “this page’s child pages”.

1 Like

To add to what bep said, this is very relevantI should probably just add that to the documentation.