Default config values not overridden by custom config values

As per the Hugo documentation,
“The user can choose to override that default with one or more site config files using the command-line --config switch.”
However, it seems to me that the default config values actually override the custom config values. Consider the following example:

Some default config

# config/default/config.toml
someParam = "default value"

A custom config file

# my_custom_config.toml
someParam = "new value"

When doing hugo --config my_custom_config.toml I’d expect to have someParam be updated to "new value", but it is not. Removing the line someParam = "default value" from the default config file does produce “new value” as a result, so the values in the config file are definitely being found/used by Hugo, just not when there is a default one present.
Am I doing something wrong here?

Since you didn’t put any link to repository, I can’t test my solution.

So, you can test it and tell whether it works.

Move the config.toml from config/default/config.toml and put it in root of repo. Also rename it to to something like another_config.toml.

With this structure:

./
├── config/
│   └── _default/
│       └── config.toml
└── config-other.toml

you must specify the location of the configuration directory:

hugo --config config-other.toml --configDir config/_default

With this structure:

./
├── config.toml
└── config-other.toml

do this:

hugo --config config-other.toml
1 Like