gohugoio/hugo · error

language not found

Error message

language %q not found

What it means

The hugo config --lang command looks up the given language code in the site's LanguageConfigMap (config.go:68-73). If the code is not among the languages defined in the site's languages configuration, this error is returned. When --lang is omitted, the default content language is used instead.

Solutions

  1. Verify the language code exists in your languages configuration block
  2. Omit --lang to use the default content language
  3. Check for case sensitivity and trailing whitespace in the flag value

Example fix

# before
hugo config --lang fr   # fr not in config
# after: add the language to config
[languages.fr]
weight = 10
# or just omit the flag
hugo config
Defensive patterns

Strategy: validation

Validate before calling

// Validate the --lang value against configured languages before running.
func validateLanguage(lang string, configured map[string]bool) error {
    if lang == "" {
        return nil
    }
    if !configured[lang] {
        return fmt.Errorf("language %q not found", lang)
    }
    return nil
}

Prevention

When it happens

Trigger: Running hugo config --lang fr when 'fr' is not defined in the [languages] section of the site config.

Common situations: Typo in the language code; querying a language not enabled on the site; case mismatch between flag and config.

Related errors


AI-assisted analysis of gohugoio/hugo@52c9bd7908 (2026-08-09). Data as JSON: /api/errors/3c0830dabd3f54a8. Report an issue: GitHub.

Appendix: source

Thrown at commands/config.go:72

func (c *configCommand) Commands() []simplecobra.Commander {
	return c.commands
}

func (c *configCommand) Name() string {
	return "config"
}

func (c *configCommand) Run(ctx context.Context, cd *simplecobra.Commandeer, args []string) error {
	conf, err := c.r.ConfigFromProvider(configKey{counter: c.r.configVersionID.Load()}, flagsToCfg(cd, nil))
	if err != nil {
		return err
	}
	var config *allconfig.Config
	if c.lang != "" {
		var found bool
		config, found = conf.configs.LanguageConfigMap[c.lang]
		if !found {
			return fmt.Errorf("language %q not found", c.lang)
		}
	} else {
		config = conf.configs.LanguageConfigMap[conf.configs.Base.DefaultContentLanguage]
	}

	var buf bytes.Buffer
	dec := json.NewEncoder(&buf)
	dec.SetIndent("", "  ")
	dec.SetEscapeHTML(false)

	if err := dec.Encode(parser.ReplacingJSONMarshaller{Value: config, KeysToLower: true, OmitEmpty: !c.printZero}); err != nil {
		return err
	}

	format := strings.ToLower(c.format)

	switch format {
	case "json":

View on GitHub (pinned to 52c9bd7908)