HUGO
Menu
GitHub 89555 stars Mastodon

Configure roles

Configure roles.
New in v0.153.0

This 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 the defaultContentRole. Default is false.

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
      }
   }
}