.Paginate method not working in .RegularPagesRecursive

Hello friends,

I’ve been working last 2 months on this site for a local financial online magazine in my country.

It’s almost done, but there is one piece I can’t figure out what is going on.

The site has multiple sections as you can see in the footer:

The problem is with the layout for lists, when I’m on each section I need to show most recent on that section plus the next pages for that section.

As you can see in this list template: hugo.revistagestion.ec/list.html at main · marceloandrader/hugo.revistagestion.ec · GitHub

when i request the first 20 from .RegularPagesRecursive the site works fine, each section has it’s own articles.
when I request all the pages from .RegularPagesRecursive it also works fine but the sections are too big because this site has an historical list of pages of about 24k articles, (the current github doesn’t have the whole content)
The issue arise when I try to do the (.Paginate .RegularPagesRecursive).Pages, then the site goes nuts, all sections have the same list of articles.

Not sure if I’m doing something wrong with the structure or hugo is not doing something correctly.

I tried to recreate the issue in another small site, but there it works (GitHub - marceloandrader/paginate-sections) in the url /sections/one it display the list of pages and the nested one. in /sections/two it display the articles of that section only. (Expected result)

BTW I’m using this version of hugo: hugo v0.101.0-466fa43c16709b4483689930a4f9ac8add5c9f66+extended linux/amd64 BuildDate=2022-06-16T07:09:16Z VendorInfo=gohugoio

You are paginating twice:

The .Paginator is static and cannot change once created.

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.

See:
https://gohugo.io/templates/pagination/#list-paginator-pages

Thank you so much! @jmooring

This happens because I copied and pasted code from random sites.

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