{"id":"3c0830dabd3f54a8","repo":"gohugoio/hugo","slug":"language-q-not-found","errorCode":null,"errorMessage":"language %q not found","messagePattern":"language %q not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"commands/config.go","lineNumber":72,"sourceCode":"func (c *configCommand) Commands() []simplecobra.Commander {\n\treturn c.commands\n}\n\nfunc (c *configCommand) Name() string {\n\treturn \"config\"\n}\n\nfunc (c *configCommand) Run(ctx context.Context, cd *simplecobra.Commandeer, args []string) error {\n\tconf, err := c.r.ConfigFromProvider(configKey{counter: c.r.configVersionID.Load()}, flagsToCfg(cd, nil))\n\tif err != nil {\n\t\treturn err\n\t}\n\tvar config *allconfig.Config\n\tif c.lang != \"\" {\n\t\tvar found bool\n\t\tconfig, found = conf.configs.LanguageConfigMap[c.lang]\n\t\tif !found {\n\t\t\treturn fmt.Errorf(\"language %q not found\", c.lang)\n\t\t}\n\t} else {\n\t\tconfig = conf.configs.LanguageConfigMap[conf.configs.Base.DefaultContentLanguage]\n\t}\n\n\tvar buf bytes.Buffer\n\tdec := json.NewEncoder(&buf)\n\tdec.SetIndent(\"\", \"  \")\n\tdec.SetEscapeHTML(false)\n\n\tif err := dec.Encode(parser.ReplacingJSONMarshaller{Value: config, KeysToLower: true, OmitEmpty: !c.printZero}); err != nil {\n\t\treturn err\n\t}\n\n\tformat := strings.ToLower(c.format)\n\n\tswitch format {\n\tcase \"json\":","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/commands/config.go#L54-L90","documentation":"Raised by `hugo config` when the value passed via `--lang` is not a key in the site's LanguageConfigMap (commands/config.go:70-73). Hugo builds one merged config per configured language; if the requested language code was never declared in the site configuration, there is no config object to display, so the command fails fast instead of printing the wrong language's settings.","triggerScenarios":"Running `hugo config --lang <code>` where <code> does not match any key under `languages` in hugo.toml/hugo.yaml (e.g. `hugo config --lang en-us` when the config declares `en`). Also triggered when the site has no `languages` block at all and any --lang other than the default content language is requested.","commonSituations":"Typos or case/region mismatches in language codes (`en-US` vs `en`); running the command in a monorepo directory whose config doesn't define the expected language; a language recently removed or renamed in config; confusing `defaultContentLanguage` with a declared language entry.","solutions":["Check the declared language keys: run `hugo config | grep -A5 languages` or inspect the `languages` section of your site config, and pass one of those exact keys to --lang.","Fix the language key spelling/case — the lookup is an exact map-key match against your config's language identifiers.","If the language should exist, add it under `[languages.<code>]` in hugo.toml before querying it.","Omit --lang to display the config for defaultContentLanguage."],"exampleFix":"# before\nhugo config --lang en-US   # config declares [languages.en]\n# after\nhugo config --lang en","handlingStrategy":"validation","validationCode":"// Verify the language key exists in config before requesting it\nlangs := conf.Languages\nfound := false\nfor _, l := range langs {\n    if l.Lang == wantedLang {\n        found = true\n        break\n    }\n}\nif !found {\n    // handle: list valid languages to the user\n}","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"not found\") {\n    // report valid languages from config and exit non-zero\n}","preventionTips":["Only pass --lang values that appear in the site config's languages section","Enumerate configured languages first and validate CLI input against that list","Fail fast with a helpful message listing valid language codes instead of retrying"],"tags":["hugo","cli","config","i18n"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}