This is the same issue as was discussed in this post.
Among many articles, some have a param in front matter such as exclude_flags: ["something", "or something else"].
I’ve been unable to filter articles with this param from paginated results without getting gaps, as described in the previous post about this. One of my many attempts to do so is below, but this still results in the undesired content items appearing in the paginated results.
No, when I don’t have any exclude flags exclude_flags does not appear in front matter, but I wanted to account for that in case it happens in the future.
I have also tried the following without luck (and many other variations):
Yes, that indeed works perfectly–without using .Paginate. For example, the following fails to filter out articles with an exclude flag from paginated results:
{{ $include_pages := where .Pages "Params.exclude_flags" nil }}
{{ $paginator := .Paginate $include_pages}}
{{ range $paginator.Pages }}
{{ partial "article/card.html" . }}
{{ end }}
If you call .Paginator or .Paginate multiple times on the same page, you should ensure all the calls are identical. Once either.Paginator or .Paginate is called while generating a page, its result is cached, and any subsequent similar call will reuse the cached result. This means that any such calls which do not match the first one will not behave as written.