Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This commit adds support for a configuration directory (default
config
). The different pieces in this puzzle are:--environment
(or-e
) flag. This can also be set with theHUGO_ENVIRONMENT
OS environment variable. The value forenvironment
defaults toproduction
when runninghugo
anddevelopment
when runninghugo server
. You can set it to any value you want (e.g.hugo server -e "Sensible Environment"
), but as it is used to load configuration from the file system, the letter case may be important. You can get this value in your templates with{{ hugo.Environment }}
.--configDir
flag (defaults toconfig
below your project). This can also be set withHUGO_CONFIGDIR
OS environment variable.If the
configDir
exists, the configuration files will be read and merged on top of each other from left to right; the right-most value will win on duplicates.Given the example tree below:
If
environment
isproduction
, the left-mostconfig.toml
would be the one directly below the project (this can now be omitted if you want), and then_default/config.toml
and finallyproduction/config.toml
. And since these will be merged, you can just provide the environment specific configuration setting in you production config, e.g.enableGitInfo = true
. The order within the directories will be lexical (config.toml
and thenparams.toml
).Some configuration maps support the language code in the filename (e.g.
menus.en.toml
):menus
(menu
also works) andparams
.Also note that the only folders with "a meaning" in the above listing is the top level directories below
config
. Themenus
sub folder is just added for better organization.We use
TOML
in the example above, but Hugo also supportsJSON
andYAML
as configuration formats. These can be mixed.