hugo/content/en/methods/page/Weight.md
Bjørn Erik Pedersen 9b0050e9aa Squashed 'docs/' content from commit 5c085a37b
git-subtree-dir: docs
git-subtree-split: 5c085a37b297bf12f59efeaae591418ec025c10d
2024-01-27 10:48:33 +01:00

883 B

title description categories keywords action
Weight Returns the weight of the given page as defined in front matter.
related returnType signatures
int
PAGE.Weight

The Weight method on a Page object returns the weight of the given page as defined in front matter.

{{< code-toggle file=content/recipes/sushi.md fm=true >}} title = 'How to make spicy tuna hand rolls' weight = 42 {{< /code-toggle >}}

Page weight controls the position of a page within a collection that is sorted by weight. Assign weights using non-zero integers. Lighter items float to the top, while heavier items sink to the bottom. Unweighted or zero-weighted elements are placed at the end of the collection.

Although rarely used within a template, you can access the value with:

{{ .Weight }} → 42