hugo.Sites
Returns a collection of all sites for all dimensions.
Syntax
hugo.Sites
Returns
page.Sites
The returned collection follows a hierarchical sort where each subsequent dimension acts as a tie-breaker for the one above it.
- Language is sorted by weight in ascending order, falling back to lexicographical order if weights are tied or undefined.
- Version is then sorted by weight in ascending order, with Hugo defaulting to a descending semantic sort for any ties.
- Role is finally sorted by weight in ascending order, using lexicographical order as the final fallback.
With this project configuration:
defaultContentLanguage: en
defaultContentLanguageInSubdir: true
defaultContentVersionInSubdir: true
languages:
de:
contentDir: content/de
direction: ltr
label: Deutsch
locale: de-DE
title: Projekt Dokumentation
weight: 1
en:
contentDir: content/en
direction: ltr
label: English
locale: en-US
title: Project Documentation
weight: 2
versions:
v1.0.0: {}
v2.0.0: {}
v3.0.0: {}
defaultContentLanguage = 'en'
defaultContentLanguageInSubdir = true
defaultContentVersionInSubdir = true
[languages]
[languages.de]
contentDir = 'content/de'
direction = 'ltr'
label = 'Deutsch'
locale = 'de-DE'
title = 'Projekt Dokumentation'
weight = 1
[languages.en]
contentDir = 'content/en'
direction = 'ltr'
label = 'English'
locale = 'en-US'
title = 'Project Documentation'
weight = 2
[versions]
[versions.'v1.0.0']
[versions.'v2.0.0']
[versions.'v3.0.0']
{
"defaultContentLanguage": "en",
"defaultContentLanguageInSubdir": true,
"defaultContentVersionInSubdir": true,
"languages": {
"de": {
"contentDir": "content/de",
"direction": "ltr",
"label": "Deutsch",
"locale": "de-DE",
"title": "Projekt Dokumentation",
"weight": 1
},
"en": {
"contentDir": "content/en",
"direction": "ltr",
"label": "English",
"locale": "en-US",
"title": "Project Documentation",
"weight": 2
}
},
"versions": {
"v1.0.0": {},
"v2.0.0": {},
"v3.0.0": {}
}
}
This template:
<ul>
{{ range hugo.Sites }}
<li><a href="{{ .Home.RelPermalink }}">{{ .Title }} {{ .Version.Name }}</a></li>
{{ end }}
</ul>Produces a list of links to each home page:
<ul>
<li><a href="/v3.0.0/de/">Projekt Dokumentation v3.0.0</a></li>
<li><a href="/v2.0.0/de/">Projekt Dokumentation v2.0.0</a></li>
<li><a href="/v1.0.0/de/">Projekt Dokumentation v1.0.0</a></li>
<li><a href="/v3.0.0/en/">Project Documentation v3.0.0</a></li>
<li><a href="/v2.0.0/en/">Project Documentation v2.0.0</a></li>
<li><a href="/v1.0.0/en/">Project Documentation v1.0.0</a></li>
</ul>To render a link to the home page of the default site:
{{ with hugo.Sites.Default }}
<a href="{{ .Home.RelPermalink }}">{{ .Title }}</a>
{{ end }}With the configuration above, this renders a link to the home page of the English version v3.0.0 site. The default site is the site with the default language, default version, and default role, regardless of its position in the collection. In this example the three German sites appear first due to their lower language weight, but English is the default language per the defaultContentLanguage setting.
Last updated:
August 21, 2026
:
content: Fix description of default language/version/role selection (1c613349f)
Improve this page