Get regular pages in section with nested sections

My site has the content structure shown below (there are more nested sections not included here). The _index.md file for the blog section has a cascade of type: post. I would like to show the regular page with pagination within the blog layout, but only the nested sections appear on the /blog/ page when $paginator.Pages is called. I want to know if this is possible to achieve this (and how to) without having to set layout/type params in every post.

content
│   ├───en
│   │   │   _index.md
│   │   │
│   │   ├───blog
│   │   │   │   _index.md
│   │   │   │
│   │   │   ├───news
│   │   │   │       lorem.md
│   │   │   │       ipsum.md
│   │   │   │       _index.md
│   │   │   ├───tales
│   │   │   │       dola.md
│   │   │   │       amet.md
│   │   │   │       _index.md

You want every pages of your site (not included in the schema) to be listed on the blog/list.html layout? If so:

{{ $paginator := .Paginate site.RegularPages }}

But I assume you’ve tried that.

I am filtering with where and adding the .Pages for $paginator is what’s messing up the result. Here’s my variable for $page and $paginator

{{- $p1 := where (where site.RegularPages "Type" "post") "Params.page_number" nil }}
{{- $p2 := where (where site.Pages "Type" "post") "Layout" "multipage" }}
{{- $page := union $p1 $p2 -}}
{{- $paginator := .Paginate ($page.ByDate.Reverse) -}}

So doing {{ range $paginator.Pages }} messes the whole thing up.

Indeed! Same result. Removing the _index.md file from the nested section, or moving posts from nested section to the root of the blog page works, but that is not my intended result. I am avoiding using frontmatter params (and taxonomies) since I move my content between sections/nested sections now and then or add new content/remove old content occasionally.

Would love to help but hard without a repo? Do you have one or can setup a minimal one to replicate the issue?

1 Like

I tested my theme again from scratch. A cached .Paginator was the culprit.

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