Pagination: use the internal template with a custom $paginator

I am trying to build a custom pagination for the _default/list.html template.
The list of paginated items is working as expected.
I would like to use the _internal/pagination.html template with my custom $paginator for the navigation, following the docs here, but it’s not working.

Here is part of my code (I have to thank @pointyfar for the solution proposed here:

    {{ $pages := where .Data.Pages "Type" .Section }}
    {{ $sorted := ($pages.ByParam "myDate").Reverse }}
    {{ $paginator := .Paginate $sorted 10 }}
    {{ range $paginator.Pages }}
         {{ .Title }}
    {{ end }}
{{ template "_internal/pagination.html" . }}

Looking at the internal template code here it seems to use .Paginator to build the navigation menu instead of $paginator so either:

  • am I doing something wrong
  • the documentation is not correct

Any ideas?

Well, it’s working.
I simple didn’t have enough contents to make the test (I used a 10-items pagination with 10 articles…).

I still want to figure how how $.Paginator is linked to $paginator.

1 Like