HUGO
Menu
GitHub 88294 stars Mastodon

Configure page

Configure page behavior.
New in v0.133.0

The default sort order for page collections, used when no other criteria are set, follows this priority:

  1. weight (ascending)
  2. date (descending)
  3. linkTitle falling back to title (ascending)
  4. logical path (ascending)

Hugo uses the default sort order to determine the next and previous page relative to the current page when calling these methods on a Page object:

This is based on this default project configuration:

page:
  nextPrevInSectionSortOrder: desc
  nextPrevSortOrder: desc
[page]
  nextPrevInSectionSortOrder = 'desc'
  nextPrevSortOrder = 'desc'
{
   "page": {
      "nextPrevInSectionSortOrder": "desc",
      "nextPrevSortOrder": "desc"
   }
}
nextPrevInSectionSortOrder
(string) The sort order used to determine the next and previous page within the same section when calling NextInSection or PrevInSection on a Page object. Valid values are asc (ascending) or desc (descending). Default is desc.
nextPrevSortOrder
(string) The sort order used to determine the next and previous page when calling Next or Prev on a Page object. Valid values are asc (ascending) or desc (descending). Default is desc.

To reverse the meaning of next and previous:

page:
  nextPrevInSectionSortOrder: asc
  nextPrevSortOrder: asc
[page]
  nextPrevInSectionSortOrder = 'asc'
  nextPrevSortOrder = 'asc'
{
   "page": {
      "nextPrevInSectionSortOrder": "asc",
      "nextPrevSortOrder": "asc"
   }
}

These settings do not apply to the Next or Prev methods on a Pages object.