Exclude page inside Collection of regular pages

I used to have set in frontmatter hidden: true to exclude pages from paginator. This was set in following code (shortened version):

{{ $p := where site.RegularPages "Params.hidden" "ne" true }}
{{ $pp := (.Paginate $p).Pages }}
{{ range $pp }}

<p {{ if eq (index $pp 0).Permalink .Permalink }} class="first" {{ else }} class="other" {{ end }}>{{ .Title }}</p>

{{ end }}

I used (been advised on forum to use) Collection of pages and index to catch first post and apply class different to other.

This was done approx April 2022 or bit after.
Unsure when, but this stop working and among pages in range the ones with hidden: true started appearing, which is strange, as they shall be excluded.

Am I am missing some changed to Hugo over time?

Currently on 0.111.3.

I also tried removing index to check if exclusion working in first place following this: How to Exclude Pages from Paginator - #2 by bep

{{ $paginator := .Paginator }}
{{ $paginator := .Paginate (where site.RegularPages "Params.hidden" "ne" true) }}
{{ range $paginator.Pages }}

but still pages with hidden: true are returned hence I am confused.

Ok, I sort this out.

Change the whole logic here:

{{range $i, $e := where .Paginator.Pages ".Page.Params.hidden" "ne" true }}

<p {{ if $i }} class="other" {{ else }} class="first" {{ end }}>{{ .Title }}</p>

{{ end }}


…the above won’t work because once you invoke either .Paginator or .Paginate the result is cached.

1 Like

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