From ef3a925647ddbb96f004d792983d65aac93e62ec Mon Sep 17 00:00:00 2001 From: bep Date: Tue, 31 Mar 2015 19:12:54 +0200 Subject: [PATCH] Add pager size argument to paginator methods Fixes #1013 --- content/extras/pagination.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/content/extras/pagination.md b/content/extras/pagination.md index 598f4b077..da7cc38c7 100644 --- a/content/extras/pagination.md +++ b/content/extras/pagination.md @@ -17,7 +17,7 @@ Hugo supports pagination for the home page, sections and taxonomies. It's built Pagination can be configured in the site configuration (e.g. `config.toml`): -* `Paginate` (default `10`) +* `Paginate` (default `10`) (this setting can be overridden in the template) * `PaginatePath` (default `page`) Setting `Paginate` to a positive value will split the list pages for the home page, sections and taxonomies into chunks of that size. But note that the generation of the pagination pages for sections, taxonomies and home page is *lazy* --- the pages will not be created if not referenced by a `.Paginator` (see below). @@ -35,6 +35,12 @@ There are two ways to configure and use a `.Paginator`: For a given **Node**, it's one of the options above. The `.Paginator` is static and cannot change once created. + +The global page size setting (`Paginate`) can be overridden by providing a positive integer as the last argument. The examples below will give five items per page: + +* `{{ range (.Paginator 5).Pages }}` +* `{{ $paginator := .Paginate (where .Data.Pages "Type" "post") 5 }}` + ## Build the navigation The `.Paginator` contains enough information to build a paginator interface.