Override Paginate config in template

The pagination doc,says

Pagination can be configured in your site configuration:

default = 10. This setting can be overridden within the template.

Does “template” mean site configuration file or actual layout html templates?
I’m a new comer to Go Lang and GoLang Templates, so my amateurish attempts of trying to set the PageSize property of .Paginator obviously failed (ie: $paginator.PageSize := 5), since the doc says the Paginator object is static and cannot be changed after initialization.

So is it possible to override the Paginate config in html templates? If so, what is the proper way to do it? I’ve been unable to find an example…


The docs have an example here: https://gohugo.io/templates/pagination/#list-paginator-pages

1 Like

oh my…haha…I don’t know why that example just went right through my head. Thank you!

The global page size setting (Paginate) can be overridden by providing a positive integer as the last argument. The examples below will give five items per page:

{{ range (.Paginator 5).Pages }}
{{ $paginator := .Paginate (where .Pages "Type" "posts") 5 }}