gohugoio/hugo · error

default language %q is disabled

Error message

default language %q is disabled

What it means

Raised in LanguagesInternal.init (langs/config.go:169) when the language matching defaultContentLanguage is disabled — either via its own `disabled: true` setting or by appearing in `disableLanguages`. Hugo must always render the default content language (it anchors URL structure and fallbacks), so disabling it is a contradiction rejected at config time.

Source

Thrown at langs/config.go:169

			ls.LanguageConfigs[k] = v
		}

		if k == "" {
			return "", errors.New("language name cannot be empty")
		}

		if err := paths.ValidateIdentifier(k); err != nil {
			return "", fmt.Errorf("language name %q is invalid: %s", k, err)
		}

		var isDefault bool
		if k == defaultContentLanguage {
			isDefault = true
			defaultSeen = true
		}

		if isDefault && v.Disabled {
			return "", fmt.Errorf("default language %q is disabled", k)
		}

		if !v.Disabled {
			ls.Sorted = append(ls.Sorted, LanguageInternal{Name: k, Default: isDefault, LanguageConfig: v})
		}
	}

	// Sort by weight if set, then by name.
	sort.SliceStable(ls.Sorted, func(i, j int) bool {
		ri, rj := ls.Sorted[i], ls.Sorted[j]
		if ri.Weight == rj.Weight {
			return ri.Name < rj.Name
		}
		if rj.Weight == 0 {
			return true
		}
		if ri.Weight == 0 {
			return false

View on GitHub ↗ (pinned to 8a468df065)

Solutions

  1. Change defaultContentLanguage to a language that remains enabled.
  2. Remove the default language from disableLanguages (or drop `disabled = true` on it).
  3. If you meant to retire that language, first switch defaultContentLanguage, then disable it.

Example fix

# before
defaultContentLanguage = "en"
disableLanguages = ["en"]
# after
defaultContentLanguage = "fr"
disableLanguages = ["en"]
Defensive patterns

Strategy: validation

Validate before calling

def := cfg.GetString("defaultContentLanguage")
if langCfg, ok := cfg.GetStringMap("languages")[def].(map[string]any); ok {
    if disabled, _ := langCfg["disabled"].(bool); disabled {
        return fmt.Errorf("defaultContentLanguage %q is disabled", def)
    }
}
for _, d := range cfg.GetStringSlice("disableLanguages") {
    if d == def { return fmt.Errorf("defaultContentLanguage %q is in disableLanguages", def) }
}

Prevention

When it happens

Trigger: Config with `defaultContentLanguage = "en"` plus `disableLanguages = ["en"]`, or `[languages.en] disabled = true` while en is (explicitly or by default) the defaultContentLanguage.

Common situations: Trying to temporarily turn off the primary language during a migration to multilingual, forgetting that defaultContentLanguage defaults to "en" when disabling en, or environment-specific config overlays disabling the wrong language.

Related errors


AI-assisted analysis of gohugoio/hugo@8a468df065 (2026-07-31). Data as JSON: /data/errors/551ca5e6af5e3207.json. Report an issue: GitHub ↗.