Custom pagination is not working

I’m having some difficulty getting custom pagination working, and I’m not sure what I’m doing wrong. On my home/index page, I have a pagination of content, and up until now I’ve been using the default .Paginator. However, I want to use a custom one that filters out posts that have draft: true set in their parameters.

Currently, I’m doing $pag := .Paginate (where .Site.RegularPages "Params.hidden" "ne" "true" and then loop over all the pages range $pag.Pages. However, this includes a post with hidden: true in the front-matter. What am I doing wrong?

Thanks in advance!

It sounds like your front matter value is a boolean, but your where statement performs a string comparison.

https://gohugo.io/functions/where/#use-where-with-booleans

1 Like