Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commands may apply configuration from all environments #14763

@jmooring

Description

@jmooring

The problem occurs with v0.112.0 and later.


When running certain subcommands (new, config, mod, convert, list, deploy), environment-specific configuration from all environments is applied rather than only the active one.

Cause

These subcommands bypass hugobuilder.loadConfig() where the active environment was previously resolved. With the environment unresolved, config.LoadConfigFromDir receives an empty string, causing it to walk the entire config directory — including subdirectories for non-active environments — and merge all settings together.

Example

With this config layout:

config/_default/hugo.toml
config/staging/params.toml   ← myparam = "foo"

Running hugo config (environment defaults to production) incorrectly outputs:

myparam = 'foo'.

Fix

Resolve the active environment in ConfigFromProvider before building the ConfigSourceDescriptor, mirroring the logic already present in hugobuilder.loadConfig().

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions