You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/en/methods/page/Rotate.md
+22-7Lines changed: 22 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
---
2
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 weight.
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
4
categories: []
5
5
keywords: []
6
6
params:
@@ -11,33 +11,48 @@ params:
11
11
12
12
{{< new-in 0.153.0 />}}
13
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 by the dimension's weight. For example, rotating along `language` returns all language variants that share the current page's version and role.
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
15
16
16
The `DIMENSION` argument must be one of `language`, `version`, or `role`.
17
17
18
-
To render a list of all translations of the current page, including the current page:
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 all versions of the current page, use the following code block.
19
31
20
32
```go-html-template
21
-
{{ with .Rotate "language" }}
33
+
{{/* Returns versions sorted by weight ascending, then semantic version descending */}}
0 commit comments