ByLanguage
Returns the given page collection sorted by language.
Syntax
PAGES.ByLanguage
Returns
page.Pages
When sorting by language, Hugo orders the page collection using the following priority:
- Language weight (ascending)
- Date (descending)
- LinkTitle (ascending)
This method is rarely, if ever, needed. Page collections that already contain multiple languages, such as those returned by the Rotate, Translations, or AllTranslations methods on a Page object, are already sorted by language weight.
This contrived example aggregates pages from all sites and then sorts them by language:
{{ $p := slice }}
{{ range hugo.Sites }}
{{ range .Pages }}
{{ $p = $p | append . }}
{{ end }}
{{ end }}
{{ range $p.ByLanguage }}
<h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
{{ end }}To sort in descending order:
{{ range $p.ByLanguage.Reverse }}
<h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
{{ end }}Last updated:
February 25, 2026
:
Merge commit '0c2fa2460f485e0eca564dcccf36d34538374922' (b0d3364f1)
Improve this page