This gist let's you return previous/next pages based on a frontmatter parameter in Hugo. In this exmaple, the frontmatter parameter is called position
, where lower positions come first.
This prev / next navigation is looping: if there is no "next >" entry anymore, the first entry of the collection will be linked. Same for "< prev": if there is no previous element, the last element of the collection will be linked.
<div class="nav-prev-next">
{{ $currentSection := (($.Site.GetPage "section" .Section).Pages.ByParam "position") }}