| 1 |
--- |
| 2 |
title: Configure roles |
| 3 |
linkTitle: Roles |
| 4 |
description: Configure roles. |
| 5 |
categories: [] |
| 6 |
keywords: [] |
| 7 |
--- |
| 8 |
|
| 9 |
{{< new-in 0.153.0 />}} |
| 10 |
|
| 11 |
This is the default configuration: |
| 12 |
|
| 13 |
{{< code-toggle config=roles />}} |
| 14 |
|
| 15 |
## Base settings |
| 16 |
|
| 17 |
Configure the following base settings: |
| 18 |
|
| 19 |
{{< code-toggle file=hugo >}} |
| 20 |
defaultContentRole = 'guest' |
| 21 |
defaultContentRoleInSubdir = false |
| 22 |
{{< /code-toggle >}} |
| 23 |
|
| 24 |
`defaultContentRole` |
| 25 |
: (`string`) The project's [default role](g). When one or more roles are defined, this value must match one of the defined role names. |
| 26 |
|
| 27 |
`defaultContentRoleInSubdir` |
| 28 |
: (`bool`) Whether to publish the default content role to a subdirectory matching the [`defaultContentRole`](#defaultcontentrole). Default is `false`. |
| 29 |
|
| 30 |
## Role settings |
| 31 |
|
| 32 |
Use the following setting to define how Hugo orders roles. |
| 33 |
|
| 34 |
`weight` |
| 35 |
: (`int`) The role [weight](g). When set to a non-zero value, this is the primary sort criteria for this role. |
| 36 |
|
| 37 |
## Sort order |
| 38 |
|
| 39 |
Hugo sorts roles by weight in ascending order, then lexicographically in ascending order. This affects build order and complement selection. |
| 40 |
|
| 41 |
## Example |
| 42 |
|
| 43 |
The following configuration demonstrates how to define multiple roles with specific weights. |
| 44 |
|
| 45 |
{{< code-toggle >}} |
| 46 |
[roles.guest] |
| 47 |
weight = 20 |
| 48 |
[roles.member] |
| 49 |
weight = 10 |
| 50 |
{{< /code-toggle >}} |