{"id":"42b005b52bb6407d","repo":"gohugoio/hugo","slug":"invalid-timezone-for-language-q-w","errorCode":null,"errorMessage":"invalid timeZone for language %q: %w","messagePattern":"invalid timeZone for language %q: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"langs/language.go","lineNumber":183,"sourceCode":"}\n\n// Deprecated: Use Label instead.\nfunc (l *Language) LanguageName() string {\n\thugo.DeprecateWithLogger(\".Language.LanguageName\", \"Use .Language.Label instead.\", \"v0.158.0\", l.Logger())\n\treturn l.Label()\n}\n\nfunc (l *Language) Label() string {\n\tif l.LanguageConfig.Label != \"\" {\n\t\treturn l.LanguageConfig.Label\n\t}\n\treturn l.LanguageConfig.LanguageName\n}\n\nfunc (l *Language) loadLocation(tzStr string) error {\n\tlocation, err := time.LoadLocation(tzStr)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"invalid timeZone for language %q: %w\", l.Lang, err)\n\t}\n\tl.location = location\n\n\treturn nil\n}\n\nfunc (l *Language) String() string {\n\treturn l.Lang\n}\n\n// Languages is a sortable list of languages.\ntype Languages []*Language\n\nfunc (l Languages) AsSet() map[string]bool {\n\tm := make(map[string]bool)\n\tfor _, lang := range l {\n\t\tm[lang.Lang] = true\n\t}","sourceCodeStart":165,"sourceCodeEnd":201,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/langs/language.go#L165-L201","documentation":"Raised by Language.loadLocation (langs/language.go:183) when Go's time.LoadLocation cannot resolve the configured timeZone string for a language. Hugo loads a *time.Location per language to localize dates in templates and front matter; an unknown IANA zone name (or a system missing tzdata) makes that impossible, so config compilation fails with the language identified.","triggerScenarios":"Setting `timeZone` (root or `[languages.<lang>] timeZone`) to a value time.LoadLocation rejects — a misspelled or non-IANA name like \"CEST\", \"PST\" (abbreviations), \"Europe/Olso\", or any zone on a minimal system without a tz database.","commonSituations":"Using timezone abbreviations or Windows zone names instead of IANA names, typos in Area/City strings, and Docker/scratch/alpine images lacking the tzdata package so even valid names fail to load.","solutions":["Use a valid IANA zone name, e.g. \"Europe/Oslo\", \"America/New_York\", or \"UTC\".","In minimal containers, install tzdata (e.g. `apk add tzdata`) or use a Hugo binary/image that embeds it.","Check for per-language timeZone overrides in the languages block, not just the root setting."],"exampleFix":"# before\n[languages.fr]\ntimeZone = \"CEST\"\n# after\n[languages.fr]\ntimeZone = \"Europe/Paris\"","handlingStrategy":"validation","validationCode":"// Validate timeZone values are IANA names before load\nfor lang, v := range cfg.GetStringMap(\"languages\") {\n    if m, ok := v.(map[string]any); ok {\n        if tz, ok := m[\"timeZone\"].(string); ok && tz != \"\" {\n            if _, err := time.LoadLocation(tz); err != nil {\n                return fmt.Errorf(\"languages.%s.timeZone %q invalid: %w\", lang, tz, err)\n            }\n        }\n    }\n}","typeGuard":"func isValidTimeZone(tz string) bool {\n    _, err := time.LoadLocation(tz)\n    return err == nil\n}","tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"invalid timeZone\") {\n    return fmt.Errorf(\"use an IANA zone name like \\\"Europe/Oslo\\\", not an abbreviation like \\\"CET\\\": %w\", err)\n}","preventionTips":["Use IANA tz database names (America/New_York), not abbreviations or UTC offsets","Ensure the tzdata is available in minimal containers (install tzdata or import time/tzdata)","Test config on the CI image, where zone databases may differ from dev machines"],"tags":["hugo","config","timezone","multilingual"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}