Skip to content
Discussion options

You must be logged in to vote

The reason your solution doesn't work is due to a strict rule in Hugo: You can only call .Paginate once per template execution.

In your current code, you are calling .Paginate unconditionally before your if statement. Once that first .Paginate runs, Hugo freezes the pagination data (using the default sort order). The second call inside your if $tagsPage block is either ignored or simply returns the already-cached, unsorted paginator.

To fix this, you must determine the list of pages and their sort order before you initialize the paginator.

Here is the corrected code logic:

The Solution
You need to create a variable for your pages (e.g., $p), sort that variable if necessary, and then pass …

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@simgislab
Comment options

Answer selected by simgislab
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants