{"record":{"id":"a098f7f1d8d1a21b","repo":"gohugoio/hugo","slug":"failed-to-load-config-w","errorCode":null,"errorMessage":"failed to load config: %w","messagePattern":"failed to load config: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config/allconfig/load.go","lineNumber":68,"sourceCode":"\t\t}\n\t}()\n\n\tif len(d.Environ) == 0 && !hugo.IsRunningAsTest() {\n\t\td.Environ = os.Environ()\n\t}\n\n\tif d.Logger == nil {\n\t\td.Logger = loggers.NewDefault()\n\t}\n\n\tl := &configLoader{ConfigSourceDescriptor: d, cfg: config.New()}\n\t// Make sure we always do this, even in error situations,\n\t// as we have commands (e.g. \"hugo mod init\") that will\n\t// use a partial configuration to do its job.\n\tdefer l.deleteMergeStrategies()\n\tres, _, err := l.loadConfigMain(d)\n\tif err != nil {\n\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)","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/config/allconfig/load.go#L50-L86","documentation":"Wraps any error from loadConfigMain, the first phase of LoadConfig that locates and parses config files, applies flags, defaults, OS-env overrides, aliases, and computes BaseConfig (workingDir, cacheDir, themesDir). It is the umbrella error for file-level config problems: missing files, TOML/YAML/JSON parse errors, invalid cacheDir from helpers.GetCacheDir.","triggerScenarios":"A syntax error in hugo.toml/config.yaml; referencing a config file path that exists but fails to parse; `cacheDir` validation failing in helpers.GetCacheDir; an OS-env override (HUGO_*) that produces an unparseable value; an error in applyOsEnvOverrides or applyConfigAliases.","commonSituations":"A stray tab or unquoted special char in YAML config; a TOML table declared twice; `HUGO_CACHEDIR` pointing somewhere GetCacheDir rejects; merging an old config alias key that no longer maps cleanly.","solutions":["Open the wrapped error: it usually names the file and the line/column of the parse failure.","Validate the config file syntax with a TOML/YAML/JSON linter.","Check any HUGO_* env overrides for malformed values; unset them to isolate.","Confirm `cacheDir`/`workingDir`/`themesDir` resolve to valid paths."],"exampleFix":"# before (TOML duplicate table)\n[params]\nfoo = 1\n[params]\nbar = 2\n\n# after\n[params]\nfoo = 1\nbar = 2","handlingStrategy":"validation","validationCode":"# Pre-validate config file syntax with the matching parser\npython -c \"import tomllib; tomllib.loads(open('hugo.toml').read())\" || echo \"fix TOML\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Lint every config file in CI.","Avoid editing config by hand across many languages; use a generator.","Watch for duplicate TOML tables and YAML tab characters."],"tags":["config","loading","parsing","filesystem"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}