Debian Codegraph @

docs/content/en/methods/page/Rotate.md

raw
1 ---
2 title: Rotate
3 description: Returns a collection of pages that vary along the specified dimension while sharing the current page's values for the other dimensions, including the current page, sorted by the dimension's default sort order.
4 categories: []
5 keywords: []
6 params:
7 functions_and_methods:
8 returnType: page.Pages
9 signatures: [PAGE.Rotate DIMENSION]
10 ---
11
12 {{< new-in 0.153.0 />}}
13
14 The rotate method on a page object returns a collection of pages that vary along the specified [dimension](g), while holding the other dimensions constant. The result includes the current page and is sorted according to the rules of the specified dimension. For example, rotating along [language](g) returns all language variants that share the current page's [version](g) and [role](g).
15
16 The `DIMENSION` argument must be one of `language`, `version`, or `role`.
17
18 ## Sort order
19
20 Use the following rules to understand how Hugo sorts the collection returned by the `Rotate` method.
21
22 | Dimension | Primary Sort | Secondary Sort |
23 | :--- | :--- | :--- |
24 | Language | Weight ascending | Lexicographical ascending |
25 | Version | Weight ascending | Semantic version descending |
26 | Role | Weight ascending | Lexicographical ascending |
27
28 ## Examples
29
30 To render a list of the current page's language variants, including the current page, while sharing its current version and role:
31
32 ```go-html-template
33 {{/* Returns languages sorted by weight ascending, then lexicographically ascending */}}
34 {{ range .Rotate "language" }}
35 <h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
36 {{ end }}
37 ```
38
39 To render a list of the current page's version variants, including the current page, while sharing its current language and role:
40
41 ```go-html-template
42 {{/* Returns versions sorted by weight ascending, then semantic version descending */}}
43 {{ range .Rotate "version" }}
44 <h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
45 {{ end }}
46 ```
47
48 To render a list of the current page's role variants, including the current page, while sharing its current language and version:
49
50 ```go-html-template
51 {{/* Returns roles sorted by weight ascending, then lexicographically ascending */}}
52 {{ range .Rotate "role" }}
53 <h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
54 {{ end }}
55 ```