gohugoio/hugo · error
failed to create config from result
Error message
failed to create config from result: %w
What it means
Wraps the first call to fromLoadConfigResult, which decodes the freshly-parsed config map into the structured Config and per-language Config map, runs all section decoders, compiles server/cache-buster config, and builds file caches. So this is the umbrella for any decode-stage failure that is NOT a file parse error (those surface as 266). Errors 260, 261, 262 are produced inside this function and bubble up wrapped here.
Solutions
- Inspect the wrapped error chain: it typically contains a more specific 'failed to decode "<key>"' or compile error.
- Fix the named section per the inner error guidance (see errors 260-264, 273-279).
- Run `hugo config` only after the inner error is resolved.
Example fix
// no direct code fix; resolve the wrapped decoder error first // e.g. if wrapped is 'failed to decode "related"', fix the [related] section.
Defensive patterns
Strategy: try-catch
Try / catch
cfgs, err := allconfig.LoadConfig(d)
if err != nil {
// Walk errors.Is/As to find the specific decoder error.
var de *herrors.FileError
if errors.As(err, &de) { /* position info available */ }
return err
} Prevention
- Resolve file syntax (266) first; this error is purely decode-stage.
- Use `hugo config` iteratively as you fix sections.
When it happens
Trigger: Any decoder failure (languages, related, markup, build, etc.) during the first decode pass; a cache-buster or server glob/regexp compile failure in CompileConfig; file cache creation failure.
Common situations: A structurally valid config file (parses fine) but with semantically invalid section values; enabling `[server]` headers/redirects with bad globs; a `[build.cacheBusters]` entry with a bad regexp.
Related errors
- failed to create config from modules config
- failed to decode config for language
- failed to decode
- failed to load config
- --appendPort=false not supported when in multihost mode
AI-assisted analysis of gohugoio/hugo@52c9bd7908 (2026-08-09).
Data as JSON: /api/errors/37d2fa4dedf66576.
Report an issue: GitHub.
Appendix: source
Thrown at config/allconfig/load.go:73
}
if d.Logger == nil {
d.Logger = loggers.NewDefault()
}
l := &configLoader{ConfigSourceDescriptor: d, cfg: config.New()}
// Make sure we always do this, even in error situations,
// as we have commands (e.g. "hugo mod init") that will
// use a partial configuration to do its job.
defer l.deleteMergeStrategies()
res, _, err := l.loadConfigMain(d)
if err != nil {
return nil, fmt.Errorf("failed to load config: %w", err)
}
configs, err = fromLoadConfigResult(d.Fs, d.Logger, res)
if err != nil {
return nil, fmt.Errorf("failed to create config from result: %w", err)
}
moduleConfig, modulesClient, err := l.loadModules(configs, d.IgnoreModuleDoesNotExist)
if err != nil {
return nil, fmt.Errorf("failed to load modules: %w", err)
}
if len(l.ModulesConfigFiles) > 0 {
// Config merged in from modules.
// Re-read the config.
configs, err = fromLoadConfigResult(d.Fs, d.Logger, res)
if err != nil {
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...)View on GitHub (pinned to 52c9bd7908)