Pagination: Incorrect Total Pages


I have custom pagination on a web page. When I added new content, it seemed that the total pages returned were incorrect, and because of that, I have the last page that doesn’t have a list.

By the way, I’m using the default number of paginate which is 10. Also, I tried this built-in pagination and it’s still the same:
{{ template "_internal/pagination.html" . }}

Here is my iteration:

The Gist of it is that:

  • When you do a where in .Paginator.Pages you’re not changing the paginator, you’re just extracting a sub set from the paginated list.
  • There are 2 pagination methods in Hugo: 1. .Paginator (which gives you the default page set for that particular Page) and .Paginate which lets you select which Pages to include in the paginated list.

So, if you rewrite the above to:

{{ range (.Paginate ( where .Pages "Params.categories" "Sample" )).Pages }}

You should be good. But note that there can currently only be one paginator per page.

For more info, see Pagination | Hugo

1 Like

Thanks for the information! It’s working now :smiley:

1 Like

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