{"id":"2b4ee63cbb3d8bef","repo":"gohugoio/hugo","slug":"failed-to-create-config-from-modules-config-w","errorCode":null,"errorMessage":"failed to create config from modules config: %w","messagePattern":"failed to create config from modules config: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config/allconfig/load.go","lineNumber":86,"sourceCode":"\t\treturn nil, fmt.Errorf(\"failed to load config: %w\", err)\n\t}\n\n\tconfigs, err = fromLoadConfigResult(d.Fs, d.Logger, res)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to create config from result: %w\", err)\n\t}\n\n\tmoduleConfig, modulesClient, err := l.loadModules(configs, d.IgnoreModuleDoesNotExist)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to load modules: %w\", err)\n\t}\n\n\tif len(l.ModulesConfigFiles) > 0 {\n\t\t// Config merged in from modules.\n\t\t// Re-read the config.\n\t\tconfigs, err = fromLoadConfigResult(d.Fs, d.Logger, res)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to create config from modules config: %w\", err)\n\t\t}\n\t\tif err := configs.transientErr(); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to create config from modules config: %w\", err)\n\t\t}\n\t\tconfigs.LoadingInfo.ConfigFiles = append(configs.LoadingInfo.ConfigFiles, l.ModulesConfigFiles...)\n\t} else if err := configs.transientErr(); err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to create config: %w\", err)\n\t}\n\n\tconfigs.Modules = moduleConfig.AllModules\n\tconfigs.ModulesClient = modulesClient\n\n\tif !d.SkipNpmCheck && npm.NpmPackNeedsUpdate(d.Fs, configs.Modules) {\n\t\td.Logger.Warnln(`npm dependencies are out of sync, please run \"hugo mod npm pack\" (you may also want to run \"npm install\" after that)`)\n\t}\n\n\tif err := configs.Init(d.Fs, d.Logger); err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to init config: %w\", err)","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/config/allconfig/load.go#L68-L104","documentation":"After modules are resolved, if any module contributed its own config files (l.ModulesConfigFiles non-empty), Hugo re-runs fromLoadConfigResult so the module-supplied config is merged in, then checks configs.transientErr(). This error wraps a failure in that second decode pass or a deferred (transient) validation error, meaning the merged site+module config is invalid even though the site's own config alone was fine.","triggerScenarios":"A theme or module ships a hugo.toml/config.toml with sections that fail decoding, or whose values merged with the site config produce an invalid combination (e.g. module-provided output formats, params, or markup settings clashing with site settings); transientErr surfacing a deferred per-language validation failure after the merge.","commonSituations":"Upgrading a theme whose bundled config uses options from a newer Hugo than the installed binary; two modules contributing conflicting config for the same key; a site override that made sense standalone but is invalid once the theme's config merges under it.","solutions":["Inspect the wrapped error to see which section failed, then check the theme/module's own config file (in themes/<name>/ or the module cache) for that section.","Align Hugo versions: check the theme's min_version and upgrade Hugo, or pin an older theme release.","Override the offending key explicitly in your site config — site config wins over module config in the merge.","Temporarily remove module imports one at a time to identify which module's config breaks the merge."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Check mount targets in module config are valid Hugo component folders\nvalid := map[string]bool{\"content\":true,\"static\":true,\"layouts\":true,\"data\":true,\"assets\":true,\"i18n\":true,\"archetypes\":true}\nfor _, m := range mounts {\n    root := strings.Split(m.Target, \"/\")[0]\n    if !valid[root] {\n        return fmt.Errorf(\"invalid mount target %q\", m.Target)\n    }\n}","typeGuard":null,"tryCatchPattern":"conf, err := allconfig.LoadConfig(opts)\nif err != nil {\n    // modules resolved but their merged config failed to apply —\n    // check imported themes'/modules' config files, not just your own\n    return err\n}","preventionTips":["Remember imported modules contribute config; a broken key can live in a theme, not your site — check the module named in the error","Mount targets must start with a valid component folder (content, static, layouts, data, assets, i18n, archetypes)","Pin module versions so an upstream theme config change can't break your build unexpectedly","Test after hugo mod get -u before committing the update"],"tags":["hugo","modules","config","themes","merge"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}