-
-
Notifications
You must be signed in to change notification settings - Fork 8k
Description
- Page.Rotate({language,version,role})
- Site.Dimension{language,version,role})
{language,version,role}.IsDefault
,{language,version,role}.Name
(same as the key in config)
New concepts
- 3D build matrix: Languages, versions, roles.
- Sites matrix (see below)
- Sites fallbacks (see below)
- Technically, a
Site
is identified by a site vector, e.g.{0,0,0}
which is the single identifier for common, simple sites.
Sites matrix and fallbacks
Sites matrix and fallbacks can be configured on
- File mounts (currently only relevant for
content
andlayouts
mounts). - Content front matter
- Site and content cascade configuration
- For
content
, thesites.matrix
configuration will create new URLs for all matching{languages,versions,roles}
. This applies to both pages and bundled resources. - For
content
, thesites.fallbacks
configuration will borrow references (will not create new URLs) from the matching{languages,versions,roles}
to fill in any gaps. To select the fallback we prefer closer matches, and matches above in each dimension's sorter will win on ties. This means that if you have the Scandinavian languages defined in orderno,sv,da
and configure that some piece of content should act as a fallback forda
, then anysv
match will win because because it's closer. - For
layouts
,sites.matrix
configuration will be used to determine which template to use to render a piece of content. - For
layouts
,sites.fallbacks
configuration is currently not relevant.
sites:
matrix:
languages: ["**"]
versions: ["**"]
roles: ["**"]
fallbacks:
languages: ["**"]
versions: ["**"]
roles: ["**"]
The Glob expressions above uses "." as separator.
Note that this also applies to page metadata set in content adapters.
Content Adapters
Before Hugo v0.150.0
the site matrix had only one dimension, language
, and we executed a given _content.gotmpl
file with the Site
that represented the file's language (configured either in the file name, the mount config or fall back to defaultContentLanguage
). You could then invoke .EnableAllLanguages
in _content.gotmpl
to execute the same template for all Sites/languages.
In v0.150.0
we have 3 dimensions (language, version, role) and a Site
is represented by a vector of these 3, e.g. ('en', 'v2.1.0', 'guest'). And since a _content.gotmpl
can be configured for e.g. many languages, we, by default, only execute the _content.gotmpl
once with the first matching Site
. You can override this behaviour by invoking .EnableAllDimensions
. But note that you don't need to do that if the goal is just to e.g. create content across languages, since it's now possible to set sites.{languages,versions,roles}
as Glob patterns in both the file mount config or in page metadata/front matter.
Notes
- Before Hugo
v0.150.0
we rendered the project in the order ofdefaultContentLanguage
first and then in the order defined by the language (weight
thenname
). With a bigger build matrix (language, version, role), we decided to simplify this having one sort order. Note that it's very common to have thedefaultContentLanguage
listed as the first.