{"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/8a468df065a75c1c7cf9f6850f32148746590ea5/config/allconfig/allconfig.go#L1123-L1159","documentation":"Wrapped error from fromLoadConfigResult (allconfig.go:1141) when decoding the merged per-language config clone fails. Hugo clones the base config for each language whose entry overrides root keys and re-runs decodeConfigFromParams on just those keys; any decoder error (bad type, invalid value) for that language's section is wrapped with the language key.","triggerScenarios":"A `[languages.<lang>]` block containing a key whose value fails its section decoder — e.g. languages.fr.pagination.pagerSize as a string, an invalid languages.<lang>.permalinks or markup structure, or a malformed params structure under a language.","commonSituations":"Multilingual sites where a language-level override uses the wrong type or outdated key syntax after a Hugo upgrade, copy-pasting root config into a language block incorrectly, or YAML indentation putting values under the wrong language key.","solutions":["Read the wrapped inner error — it names the failing config section — and fix that key under the named language block.","Check types of language-level overrides (numbers vs strings, maps vs scalars) against the root-level equivalents.","Temporarily move the override to root config to confirm which language-level key breaks decoding.","Validate YAML/TOML syntax and indentation of the languages block."],"exampleFix":"# before (hugo.toml)\n[languages.fr.pagination]\npagerSize = \"ten\"\n# after\n[languages.fr.pagination]\npagerSize = 10","handlingStrategy":"validation","validationCode":"// Validate per-language config sections before load\n// Each [languages.xx] block must contain only known config keys with correct types\n// e.g. run: hugo config --printUnusedTemplates 2>/devev/null || hugo config\nfor lang, v := range cfg.GetStringMap(\"languages\") {\n    if _, ok := v.(map[string]any); !ok {\n        return fmt.Errorf(\"languages.%s must be a table, got %T\", lang, v)\n    }\n}","typeGuard":"func isLangTable(v any) (map[string]any, bool) {\n    m, ok := v.(map[string]any)\n    return m, ok\n}","tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"failed to decode config for language\") {\n    // Extract the language key from the message and inspect that [languages.xx] block\n    return fmt.Errorf(\"check the [languages.*] section named in the error for wrong types or unknown keys: %w\", err)\n}","preventionTips":["Keep each [languages.xx] section a table, never a scalar","Use correct types per key (weight = int, title = string, disabled = bool)","Validate config with `hugo config` after editing language blocks","Don't put site-level-only keys inside language sections"],"tags":["hugo","config","multilingual","decode"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}