I read the Next Page method and here are the results I get. Pages 1, 2 and 3 have dates in descending order (Page 3 latest)
site.RegularPages and site.RegularPages.ByDate.Reverse on Page 2 return
Prev as Page 1 and Next as Page 3
site.RegularPages.ByDate returns
Prev as Page 3 and Next as Page 1
My question is, based on the sorting direction, does it mean that it is a must to add the sorting field to the page collection? My thinking was that site.RegularPages should by default work the same as site.RegularPages.ByDate?
I see! But I am also confused because list pages (home, section) behave the opposite. site.RegularPages and site.RegularPages.ByDate.Reverse are in descending order but site.RegularPages.ByDate is in ascending order.
Hugo determines the next and previous page by sorting the page collection according to this sorting hierarchy
The “sorting hierarchy” is different than the default sort order, as described by the table beneath that line in the documentation.
The sorted page collection used to determine the next and previous page is independent of other page collections, which may lead to unexpected behavior.
To reverse the meaning of next and previous you can chain the Reverse method to the page collection definition:
The most important takeaway is… when listing a page collection, use the same collection with the PAGES.Next and PAGES.Prev methods.
I won’t lie, I am still confused about how this works in both cases, but since I set the code and it works, and I might never come back to it, I will take time to read and digest the two links you sent.