Debian Codegraph @

docs/content/en/methods/pager/TotalPages.md

raw
1 ---
2 title: TotalPages
3 description: Returns the number of pagers in the pager collection.
4 categories: []
5 keywords: []
6 params:
7 functions_and_methods:
8 returnType: int
9 signatures: [PAGER.TotalPages]
10 ---
11
12 Use the `TotalPages` method to build navigation between pagers.
13
14 ```go-html-template
15 {{ $pages := where site.RegularPages "Type" "posts" }}
16 {{ $paginator := .Paginate $pages }}
17
18 {{ range $paginator.Pages }}
19 <h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
20 {{ end }}
21
22 {{ with $paginator }}
23 <p>Pager {{ .PageNumber }} of {{ .TotalPages }}</p>
24 <ul>
25 {{ with .First }}
26 <li><a href="{{ .URL }}">First</a></li>
27 {{ end }}
28 {{ with .Prev }}
29 <li><a href="{{ .URL }}">Previous</a></li>
30 {{ end }}
31 {{ with .Next }}
32 <li><a href="{{ .URL }}">Next</a></li>
33 {{ end }}
34 {{ with .Last }}
35 <li><a href="{{ .URL }}">Last</a></li>
36 {{ end }}
37 </ul>
38 {{ end }}
39 ```