Order Pages ByTitle with Paginator

Hello,

My content structure is as followed:
– united-states
– illinois
– chicago
_index.md
office1.md
office2.md

In \united-states\illinois\chicago_index.md and each offficex.md I defined this layout
type: office
layout: office

I want to list all offices sorted by title, which I do in layouts\office\list.html. This works fine, until I want to add pagination.

{{ range .Pages.ByTitle }} - sorts offices by title

{{ range .Paginator.Pages.ByTitle }} - sorts offices by date

I’m using latest Hugo version, but let me know if more details are needed. Any help how to fix this will be appreciated.

i think you have to build a paginator with the wanted sortings

not tryed

{{ $paginator := .Paginate  .Pages.ByTitle  }}
{{ template "_internal/pagination.html" . }}
{{ range $paginator.Pages }}
   {{ .Title }}
{{ end }}
1 Like

This worked. Thank you!