Configure roles
Configure roles.
New in v0.153.0This is the default configuration:
roles:
guest:
weight: 0
[roles]
[roles.guest]
weight = 0
{
"roles": {
"guest": {
"weight": 0
}
}
}
Base settings
Configure the following base settings:
defaultContentRole: guest
defaultContentRoleInSubdir: false
defaultContentRole = 'guest'
defaultContentRoleInSubdir = false
{
"defaultContentRole": "guest",
"defaultContentRoleInSubdir": false
}
defaultContentRole- (
string) The project’s default role. When one or more roles are defined, this value must match one of the defined role names. defaultContentRoleInSubdir- (
bool) Whether to publish the default content role to a subdirectory matching thedefaultContentRole. Default isfalse.
Role settings
Use the following setting to define how Hugo orders roles.
weight- (
int) The role weight. When set to a non-zero value, this is the primary sort criteria for this role.
Sort order
Hugo sorts roles by weight in ascending order, then lexicographically in ascending order. This affects build order and complement selection.
Example
The following configuration demonstrates how to define multiple roles with specific weights.
roles:
guest:
weight: 20
member:
weight: 10
[roles]
[roles.guest]
weight = 20
[roles.member]
weight = 10
{
"roles": {
"guest": {
"weight": 20
},
"member": {
"weight": 10
}
}
}
Last updated:
August 21, 2026
:
content: Fix description of default language/version/role selection (1c613349f)
Improve this page