mirror of
https://github.com/gohugoio/hugo.git
synced 2025-09-01 22:42:45 +02:00
Merge commit '35dec7c96f7ee3eb17dd444f7067f0c776fb56ae'
This commit is contained in:
@@ -8,8 +8,8 @@ menu:
|
||||
parent: templates
|
||||
weight: 100
|
||||
weight: 100
|
||||
aliases: [/extras/pagination,/doc/pagination/]
|
||||
toc: true
|
||||
aliases: [/extras/pagination,/doc/pagination/]
|
||||
---
|
||||
|
||||
The real power of Hugo pagination shines when combined with the [`where`] function and its SQL-like operators: [`first`], [`last`], and [`after`]. You can even [order the content][lists] the way you've become used to with Hugo.
|
||||
@@ -18,10 +18,10 @@ The real power of Hugo pagination shines when combined with the [`where`] functi
|
||||
|
||||
Pagination can be configured in your [site configuration][configuration]:
|
||||
|
||||
`paginate`
|
||||
paginate
|
||||
: default = `10`. This setting can be overridden within the template.
|
||||
|
||||
`paginatePath`
|
||||
paginatePath
|
||||
: default = `page`. Allows you to set a different path for your pagination pages.
|
||||
|
||||
Setting `paginate` to a positive value will split the list pages for the homepage, sections and taxonomies into chunks of that size. But note that the generation of the pagination pages for sections, taxonomies and homepage is *lazy* --- the pages will not be created if not referenced by a `.Paginator` (see below).
|
||||
@@ -78,7 +78,7 @@ The following example shows how to create `.Paginator` before its used:
|
||||
{{ $paginator := .Paginate (where .Pages "Type" "posts") }}
|
||||
{{ template "_internal/pagination.html" . }}
|
||||
{{ range $paginator.Pages }}
|
||||
{{ .Title }}
|
||||
{{ .Title }}
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
@@ -87,52 +87,52 @@ Without the `where` filter, the above example is even simpler:
|
||||
```go-html-template
|
||||
{{ template "_internal/pagination.html" . }}
|
||||
{{ range .Paginator.Pages }}
|
||||
{{ .Title }}
|
||||
{{ .Title }}
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
If you want to build custom navigation, you can do so using the `.Paginator` object, which includes the following properties:
|
||||
|
||||
`PageNumber`
|
||||
PageNumber
|
||||
: The current page's number in the pager sequence
|
||||
|
||||
`URL`
|
||||
URL
|
||||
: The relative URL to the current pager
|
||||
|
||||
`Pages`
|
||||
Pages
|
||||
: The pages in the current pager
|
||||
|
||||
`NumberOfElements`
|
||||
NumberOfElements
|
||||
: The number of elements on this page
|
||||
|
||||
`HasPrev`
|
||||
HasPrev
|
||||
: Whether there are page(s) before the current
|
||||
|
||||
`Prev`
|
||||
Prev
|
||||
: The pager for the previous page
|
||||
|
||||
`HasNext`
|
||||
HasNext
|
||||
: Whether there are page(s) after the current
|
||||
|
||||
`Next`
|
||||
Next
|
||||
: The pager for the next page
|
||||
|
||||
`First`
|
||||
First
|
||||
: The pager for the first page
|
||||
|
||||
`Last`
|
||||
Last
|
||||
: The pager for the last page
|
||||
|
||||
`Pagers`
|
||||
Pagers
|
||||
: A list of pagers that can be used to build a pagination menu
|
||||
|
||||
`PageSize`
|
||||
PageSize
|
||||
: Size of each pager
|
||||
|
||||
`TotalPages`
|
||||
TotalPages
|
||||
: The number of pages in the paginator
|
||||
|
||||
`TotalNumberOfElements`
|
||||
TotalNumberOfElements
|
||||
: The number of elements on all pages in this paginator
|
||||
|
||||
## Additional information
|
||||
|
Reference in New Issue
Block a user