Pagination returns pages NOT in mainSections

I am at a point where I probably miss the forest because of all the trees in front of me…

I have a partial that should (and did at some point in the past) range through my main sections (a blog). Now it stopped and is ranging through all published pages.

{{- $paginator := .Paginate (where site.RegularPages "Type" "in" site.Params.mainSections) -}}
<h2 class="visually-hidden">
  Recent Posts (Page {{ $paginator.PageNumber -}})

{{- $fullcontent := false -}}
{{- if (eq $.Kind "page") -}}
  {{- $fullcontent = true -}}
{{- end -}}

{{- range $index, $item := $paginator.Pages -}}
  {{- $post := dict "context" $item "fullcontent" $fullcontent -}}
  {{- $col := "6" -}}
  {{- if eq $index 0 -}}
    {{- $col = "12" -}}
  {{- end -}}
  <div class="col-12 col-md-{{ $col }} mb-4">
    {{- partial "content/post.html" $post $post -}}
{{- end -}}

site.Params.mainSections is ["blog"]. The page itself though shows my contacts page and the 404 page which are NOT in the blog-folder.

I debugged the site.Params.mainSections and it shows as "blog", so it’s at the right spot in the config.

This whole behaviour started around “the holidays” and I am not sure if I changed anything important around that time. git blame certainly does not uncover evidence.

The repo is public, in case somebody wants a deep dive.

What might be the problem here?

Edit: The partial above is the only location in my layouts to use $paginator or .Paginate.

On L4 of /layouts/index.html I see that you are referencing /partials/content/section-posts.html and as per L4-L5 of said partial:

{{/* {{ $paginator := .Paginate (where site.RegularPages "Type" "in" site.Params.mainSections) }} */}}
{{ $paginator := .Paginate site.RegularPages }}

The mainSections filter is commented out and instead site.RegularPages populate the homepage paginated list.

It appears that you committed this change yesterday in commit 38bc562.

P.S. Also you have a problem with your Read Article links as they point to the homepage and not the individual blog posts.

Sorry, my fault, I kept the updates local so Netlify is not updating the site :wink: I forgot to upload the current state (the line is commented in again, I was trying to see what is going on there). I hid the pages for now by changing their date to ancient times so they are on the last page of the pagination. Up now is the current not working thing and the non-blog-pages are here (live).

Sorry, I cannot debug this further.
Tried cloning and generating the project locally but I am getting errors since I do not use npm.

Maybe someone else can have a further look.

1 Like

1 Like

That indeed was the culprit. Thanks :slight_smile: I’ll have to move the pagination part at the start of the page building and then cache the page number somehow it seems.

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