{"id":"6c2145d28558b993","repo":"gohugoio/hugo","slug":"failed-to-init-config-w","errorCode":null,"errorMessage":"failed to init config: %w","messagePattern":"failed to init config: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config/allconfig/load.go","lineNumber":104,"sourceCode":"\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)\n\t}\n\n\tloggers.SetGlobalLogger(d.Logger)\n\n\treturn\n}\n\n// ConfigSourceDescriptor describes where to find the config (e.g. config.toml etc.).\ntype ConfigSourceDescriptor struct {\n\tFs     afero.Fs\n\tLogger loggers.Logger\n\n\t// Config received from the command line.\n\t// These will override any config file settings.\n\tFlags config.Provider\n\n\t// Path to the config file to use, e.g. /my/project/config.toml\n\tFilename string","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/config/allconfig/load.go#L86-L122","documentation":"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.","triggerScenarios":"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`.","commonSituations":"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.","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."],"exampleFix":"# before (hugo.toml)\n[languages.en]\ntimeZone = \"America/Nowhere\"\n# after\n[languages.en]\ntimeZone = \"America/New_York\"","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"cfg, err := allconfig.LoadConfig(d)\nif err != nil {\n    return fmt.Errorf(\"loading site config: %w\", err)\n}","preventionTips":["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"],"tags":["hugo","config","initialization","go"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}