{"record":{"id":"9febc21d96b7dcdd","repo":"gohugoio/hugo","slug":"failed-to-decode-config-for-language-q-w","errorCode":null,"errorMessage":"failed to decode config for language %q: %w","messagePattern":"failed to decode config for language %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config/allconfig/allconfig.go","lineNumber":1141,"sourceCode":"\t\t\t\t\t\tdifferentRootKeys = append(differentRootKeys, kk)\n\t\t\t\t\tdefault:\n\t\t\t\t\t\t// Apply new values to the root.\n\t\t\t\t\t\tdifferentRootKeys = append(differentRootKeys, \"\")\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tdifferentRootKeys = hstrings.UniqueStringsSorted(differentRootKeys)\n\n\t\t\tif len(differentRootKeys) == 0 {\n\t\t\t\tlangConfigMap[k] = all\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\t// Create a copy of the complete config and replace the root keys with the language specific ones.\n\t\t\tclone := all.cloneForLang()\n\n\t\t\tif err := decodeConfigFromParams(fs, logger, bcfg, mergedConfig, clone, differentRootKeys); err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"failed to decode config for language %q: %w\", k, err)\n\t\t\t}\n\t\t\tif err := clone.CompileConfig(logger); err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\n\t\t\t// Adjust Goldmark config defaults for multilingual, single-host sites.\n\t\t\tif len(languagesConfig) > 1 && !isMultihost && !clone.Markup.Goldmark.DuplicateResourceFiles {\n\t\t\t\tif clone.Markup.Goldmark.RenderHooks.Image.UseEmbedded == gc.RenderHookUseEmbeddedAuto {\n\t\t\t\t\tclone.Markup.Goldmark.RenderHooks.Image.UseEmbedded = gc.RenderHookUseEmbeddedFallback\n\t\t\t\t}\n\t\t\t\tif clone.Markup.Goldmark.RenderHooks.Link.UseEmbedded == gc.RenderHookUseEmbeddedAuto {\n\t\t\t\t\tclone.Markup.Goldmark.RenderHooks.Link.UseEmbedded = gc.RenderHookUseEmbeddedFallback\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlangConfigMap[k] = clone\n\t\tcase hmaps.ParamsMergeStrategy:\n","sourceCodeStart":1123,"sourceCodeEnd":1159,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/config/allconfig/allconfig.go#L1123-L1159","documentation":"Thrown while building per-language Config clones during multilingual setup. After root-level config is decoded, fromLoadConfigResult iterates each entry in `languages`, clones the merged config, and re-runs the section decoders only for the keys that differ from root. If any of those per-language section decoders (build, markup, outputformats, etc.) fails, the failure is wrapped with the language key (e.g. \"en\", \"fr\"). It tells you WHICH language broke decoding, while the wrapped cause tells you which section/field.","triggerScenarios":"A multilingual site where one language block under [[languages.fr]] or [languages.fr.markup] contains a structurally invalid value (wrong type, unknown enum, malformed sub-map). Only happens when a language overrides a root key that is a Params map, forcing re-decode via decodeConfigFromParams in allconfig.go:1140.","commonSituations":"Copying an `en` language block to `fr` and leaving a field that only validates in one locale (e.g. a bad `markup.goldmark.parser` map); setting a language-specific `outputformats` or `mediaTypes` entry with a malformed shape; YAML indentation drift when a new language is added.","solutions":["Read the wrapped error: it names the decoder key (e.g. \"markup\") and the real cause. Fix that field in the offending language block.","Temporarily reduce the failing language block to empty `{}` and re-add keys one by one to isolate the offending field.","Diff the failing language block against the `en`/root block to spot type or key mismatches.","Run `hugo config --lang <k>` to print the decoded config for that language and inspect what differs."],"exampleFix":"# before\n[languages.fr]\nweight = 20\n[languages.fr.markup.goldmark.parser]\nattribute = \"notabool\"  # wrong type\n\n# after\n[languages.fr]\nweight = 20\n[languages.fr.markup.goldmark.parser]\nattribute = { title = \"\" }  # correct map type","handlingStrategy":"validation","validationCode":"# Before running hugo, validate each language block decodes by type-checking\n# key fields against root. Quick shell check for common type mistakes:\nfor lang in $(hugo config --renderToMemory 2>/dev/null | awk -F. '/^languages\\./{print $2}' | sort -u); do\n  echo \"checking $lang\"\n  hugo config --lang \"$lang\" >/dev/null || echo \"FAIL: $lang\"\ndone","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep language blocks structurally identical to the root/default language; only override scalar values.","When adding a new language, copy the entire default-language block and edit values rather than writing from scratch.","Run `hugo config --lang <k>` in CI for every language to catch per-language decode failures early."],"tags":["config","i18n","languages","multilingual","decoding"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}