hugo/docs/content/en/methods/page/Paginator.md
Bjørn Erik Pedersen 5fd1e74903
Merge commit '9b0050e9aabe4be65c78ccf292a348f309d50ccd' as 'docs'
```
git subtree add --prefix=docs/ https://github.com/gohugoio/hugoDocs.git master --squash
```

Closes #11925
2024-01-27 10:48:57 +01:00

1.9 KiB

title description categories keywords action
Paginator Paginates the collection of regular pages received in context.
related returnType signatures
methods/page/Paginate
page.Pager
PAGE.Paginator

Pagination is the process of splitting a list page into two or more pagers, where each pager contains a subset of the page collection and navigation links to other pagers. The number of elements on each pager is determined by the value of the paginate setting in your site configuration. The default value is 10.

You can invoke pagination on the home page template, section templates, taxonomy templates, and term templates. Each of these receive a collection of regular pages in context. When you invoke the Paginator method, it paginates the page collection received in context.

{{< code file=layouts/_default/list.html >}} {{ range .Paginator.Pages }}

{{ .LinkTitle }}

{{ end }} {{ template "_internal/pagination.html" . }} {{< /code >}}

In the example above, the internal "pagination" template creates the navigation links between pagers.

{{% note %}} Although simple to invoke, with the Paginator method you can neither filter nor sort the page collection. It acts upon the page collection received in context.

The Paginate method is more flexible, and strongly recommended.

{{% /note %}}

{{% note %}} Please note that the results of pagination are cached. Once you have invoked either the Paginator or Paginate method, the paginated collection is immutable. Additional invocations of these methods will have no effect. {{% /note %}}