Can't override .Paginator global page size

Following the tutorial Pagination | Hugo, and using their suggested method for overriding global page size doesn’t seem to work, this is my template code:

{{ $paginator := (.Paginator 5) }}
{{ range $paginator.Pages }}
...
{{ end }}

Even though I’m passing a 5 it continues to return 10 items per page, which is the global setting.

Am I missing something here?

Thanks!

My guess:

  • We generate these paginated pages on demand on first invocation for a page
  • So, if you say
    1. {{ $paginator := (.Paginator 10) }}
    2. {{ $paginator := (.Paginator 5) }}

The last invocation will return 10 pages (which, I admit, can be a bit confusing – but it’s a static site generator, so we cannot return a different page set).

Hi @bep,

Wow thank you so much! I had another definition of $paginator I didn’t know about in the baseof.html, updated that one and now all is well! :smiley:

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