{"id":"ce9ab86be5465cf8","repo":"gohugoio/hugo","slug":"outputformat-with-key-q-not-found","errorCode":null,"errorMessage":"OutputFormat with key %q not found","messagePattern":"OutputFormat with key %q not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"output/outputFormat.go","lineNumber":305,"sourceCode":"func (formats Formats) GetByName(name string) (f Format, found bool) {\n\tfor _, ff := range formats {\n\t\tif strings.EqualFold(name, ff.Name) {\n\t\t\tf = ff\n\t\t\tfound = true\n\t\t\treturn\n\t\t}\n\t}\n\treturn\n}\n\n// GetByNames gets a list of formats given a list of identifiers.\nfunc (formats Formats) GetByNames(names ...string) (Formats, error) {\n\tvar types []Format\n\n\tfor _, name := range names {\n\t\ttpe, ok := formats.GetByName(name)\n\t\tif !ok {\n\t\t\treturn types, fmt.Errorf(\"OutputFormat with key %q not found\", name)\n\t\t}\n\t\ttypes = append(types, tpe)\n\t}\n\treturn types, nil\n}\n\n// BaseFilename returns the base filename of f including an extension (ie.\n// \"index.xml\").\nfunc (f Format) BaseFilename() string {\n\treturn f.BaseName + f.MediaType.FirstSuffix.FullSuffix\n}\n\n// IsZero returns true if f represents a zero value.\nfunc (f Format) IsZero() bool {\n\treturn f.Name == \"\"\n}\n\n// MarshalJSON returns the JSON encoding of f.","sourceCodeStart":287,"sourceCodeEnd":323,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/output/outputFormat.go#L287-L323","documentation":"Raised by `Formats.GetByNames` in output/outputFormat.go when one of the requested output-format identifiers (e.g. \"HTML\", \"RSS\", \"JSON\") has no matching entry in Hugo's resolved output formats collection. Hugo looks each name up case-insensitively via `GetByName`; the first miss aborts with this error. It typically surfaces while decoding the site's `outputs` configuration or a page's `outputs` front matter into concrete formats.","triggerScenarios":"Setting `outputs` in site config (e.g. `[outputs] home = ['HTML','SearchIndex']`) or `outputs:` in page front matter with a name that is not built in and not defined under `[outputFormats]`; also `outputFormats.Get` lookups in templates or cascade-applied outputs referencing a removed custom format.","commonSituations":"Typos in format names in config; defining a custom output format in one config file but referencing it in an environment config where the definition isn't merged; copying a theme's `outputs` config without its `[outputFormats]` block; a theme update renaming a custom format.","solutions":["Check the spelling of every name under `outputs` in site config and page front matter against built-in formats (html, rss, json, amp, calendar, etc.).","If it's a custom format, define it under `[outputFormats.<name>]` (with a `mediaType`) in the same merged configuration.","Run `hugo config | grep -i outputformats` to see which formats are actually registered after config merging.","If the name comes from a theme, ensure the theme's config is loaded (check `theme`/module imports)."],"exampleFix":"# before (hugo.toml)\n[outputs]\nhome = [\"HTML\", \"SearchIndx\"]\n\n# after\n[outputFormats.SearchIndex]\nmediaType = \"application/json\"\nbaseName = \"searchindex\"\n[outputs]\nhome = [\"HTML\", \"SearchIndex\"]","handlingStrategy":"validation","validationCode":"if _, found := outputFormats.GetByName(key); !found {\n    return fmt.Errorf(\"unknown output format %q\", key)\n}","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"not found\") {\n    // list valid formats for the user\n}","preventionTips":["Look up output formats via GetByName before referencing them in config","Keep custom outputFormats definitions and outputs lists in the same config change so keys stay in sync","Validate config-driven format keys case-insensitively, since Hugo normalizes names"],"tags":["hugo","config","output-formats"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}