{"id":"d2d571ca0b9525ec","repo":"gohugoio/hugo","slug":"defaultcontentlanguage-q-not-found-in-languages-c","errorCode":null,"errorMessage":"defaultContentLanguage %q not found in languages configuration","messagePattern":"defaultContentLanguage %q not found in languages configuration","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"langs/config.go","lineNumber":202,"sourceCode":"\t\t\treturn true\n\t\t}\n\t\tif ri.Weight == 0 {\n\t\t\treturn false\n\t\t}\n\t\treturn ri.Weight < rj.Weight\n\t})\n\n\tfor i, l := range ls.Sorted {\n\t\tif l.Name == en {\n\t\t\tenIdx = i\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif !defaultSeen {\n\t\tif defaultContentLanguage != \"\" {\n\t\t\t// Set by the user, but not found in the config.\n\t\t\treturn \"\", fmt.Errorf(\"defaultContentLanguage %q not found in languages configuration\", defaultContentLanguage)\n\t\t}\n\t\t// Not set by the user, so we use the first language in the config.\n\t\tdefaultIdx := 0\n\t\tif enIdx != -1 {\n\t\t\tdefaultIdx = enIdx\n\t\t}\n\t\td := ls.Sorted[defaultIdx]\n\t\td.Default = true\n\t\tls.LanguageConfigs[d.Name] = d.LanguageConfig\n\t\tls.Sorted[defaultIdx] = d\n\t\tdefaultContentLanguage = d.Name\n\t}\n\n\t// Apply root-level locale to the default content language if it has none.\n\t// Done after defaultContentLanguage is resolved and Sorted is built so both\n\t// are updated consistently. Other languages fall back to their Lang key.\n\t// Priority: per-lang locale > root locale > per-lang languageCode > root\n\t// languageCode. Root languageCode only applies when the default language has","sourceCodeStart":184,"sourceCodeEnd":220,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/langs/config.go#L184-L220","documentation":"Raised in LanguagesInternal.init (langs/config.go:202) when the user explicitly set defaultContentLanguage but no key in the languages map matches it. Hugo only auto-picks a default (first sorted language, preferring \"en\") when defaultContentLanguage is unset; an explicit value that matches nothing is treated as a config mistake rather than silently ignored.","triggerScenarios":"`defaultContentLanguage = \"en\"` while the `languages` map only defines other keys (e.g. only `[languages.nb]`), or a typo/case mismatch between defaultContentLanguage and the language key (keys are matched exactly).","commonSituations":"Adding a languages block to a previously monolingual site without adding the default \"en\" entry, renaming a language key (en → en-us) without updating defaultContentLanguage, or theme configs assuming a language the site doesn't define.","solutions":["Set defaultContentLanguage to one of the keys actually present under `languages`.","Or add a `[languages.<defaultContentLanguage>]` entry to the languages map.","Check for exact-string mismatches (case, hyphens) between the two settings."],"exampleFix":"# before\ndefaultContentLanguage = \"en\"\n[languages.nb]\nlabel = \"Norsk\"\n# after\ndefaultContentLanguage = \"nb\"\n[languages.nb]\nlabel = \"Norsk\"","handlingStrategy":"validation","validationCode":"def := cfg.GetString(\"defaultContentLanguage\")\nlangs := cfg.GetStringMap(\"languages\")\nif len(langs) > 0 {\n    if _, ok := langs[def]; !ok {\n        return fmt.Errorf(\"defaultContentLanguage %q missing from [languages]\", def)\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["If you define a [languages] map, always include a section for defaultContentLanguage","Remember defaultContentLanguage defaults to \"en\" — add [languages.en] or change the default","When renaming a language key, update defaultContentLanguage in the same commit"],"tags":["hugo","config","multilingual","validation"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}