gohugoio/hugo · error
failed to init config: %w
Error message
failed to init config: %w
What it means
Wrapper error from Hugo's `LoadConfig` in config/allconfig/load.go: after all config files, module configs, and flags are merged, `configs.Init` compiles the final config (languages, filesystems, output formats). If Init fails, its underlying error is wrapped with this message, so it is a container for any config-compilation failure surfaced at load time.
Source
Thrown at config/allconfig/load.go:104
return nil, fmt.Errorf("failed to create config from modules config: %w", err)
}
if err := configs.transientErr(); err != nil {
return nil, fmt.Errorf("failed to create config from modules config: %w", err)
}
configs.LoadingInfo.ConfigFiles = append(configs.LoadingInfo.ConfigFiles, l.ModulesConfigFiles...)
} else if err := configs.transientErr(); err != nil {
return nil, fmt.Errorf("failed to create config: %w", err)
}
configs.Modules = moduleConfig.AllModules
configs.ModulesClient = modulesClient
if !d.SkipNpmCheck && npm.NpmPackNeedsUpdate(d.Fs, configs.Modules) {
d.Logger.Warnln(`npm dependencies are out of sync, please run "hugo mod npm pack" (you may also want to run "npm install" after that)`)
}
if err := configs.Init(d.Fs, d.Logger); err != nil {
return nil, fmt.Errorf("failed to init config: %w", err)
}
loggers.SetGlobalLogger(d.Logger)
return
}
// ConfigSourceDescriptor describes where to find the config (e.g. config.toml etc.).
type ConfigSourceDescriptor struct {
Fs afero.Fs
Logger loggers.Logger
// Config received from the command line.
// These will override any config file settings.
Flags config.Provider
// Path to the config file to use, e.g. /my/project/config.toml
Filename stringView on GitHub ↗ (pinned to 8a468df065)
Solutions
- Read the wrapped error after the colon — it names the actual failure (often a language or timezone problem).
- Check the `languages` section of your config for typos, duplicate keys, or invalid `timeZone` values.
- Run `hugo config` to inspect the merged config, including values pulled in from modules/themes.
- If it appeared after a Hugo upgrade, diff release notes for renamed/removed config keys.
Example fix
# before (hugo.toml) [languages.en] timeZone = "America/Nowhere" # after [languages.en] timeZone = "America/New_York"
Defensive patterns
Strategy: try-catch
Try / catch
cfg, err := allconfig.LoadConfig(d)
if err != nil {
return fmt.Errorf("loading site config: %w", err)
} Prevention
- Validate config files exist and parse (TOML/YAML/JSON) before calling LoadConfig
- Run hugo config on the project to surface config errors early
- Wrap the returned error with %w and surface the full chain, since this error itself wraps a root cause
When it happens
Trigger: Calling `allconfig.LoadConfig` (via `hugo`, `hugo server`, or the hugolib API) with a config that merges cleanly but fails in `Configs.Init` — e.g. an invalid language definition, a language listed in `languages` but with an inconsistent config map entry, or a `langs.NewLanguage` failure such as a bad `timeZone`.
Common situations: Multilingual sites with typos in language keys, invalid `timeZone` values per language, or module-merged configs producing an inconsistent language set after upgrading Hugo versions.
Related errors
- errConfigNotSet
- failed to compile whitelist pattern %q: %w
- failed to load config: %v
- no filesystem provided
- failed to parse timeout: %s
AI-assisted analysis of gohugoio/hugo@8a468df065 (2026-07-31).
Data as JSON: /data/errors/6c2145d28558b993.json.
Report an issue: GitHub ↗.