{"id":"f0bec5f6f63afd96","repo":"gohugoio/hugo","slug":"media-type-q-not-found-f0bec5","errorCode":null,"errorMessage":"media type %q not found","messagePattern":"media type %q not found","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"output/config.go","lineNumber":120,"sourceCode":"\t\t\t\tfor _, key := range dataVal.MapKeys() {\n\t\t\t\t\tkeyStr, ok := key.Interface().(string)\n\t\t\t\t\tif !ok {\n\t\t\t\t\t\t// Not a string key\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tif strings.EqualFold(keyStr, \"mediaType\") {\n\t\t\t\t\t\t// If mediaType is a string, look it up and replace it\n\t\t\t\t\t\t// in the map.\n\t\t\t\t\t\tvv := dataVal.MapIndex(key)\n\t\t\t\t\t\tvvi := vv.Interface()\n\n\t\t\t\t\t\tswitch vviv := vvi.(type) {\n\t\t\t\t\t\tcase media.Type:\n\t\t\t\t\t\t// OK\n\t\t\t\t\t\tcase string:\n\t\t\t\t\t\t\tmediaType, found := mediaTypes.GetByType(vviv)\n\t\t\t\t\t\t\tif !found {\n\t\t\t\t\t\t\t\treturn c, fmt.Errorf(\"media type %q not found\", vviv)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tdataVal.SetMapIndex(key, reflect.ValueOf(mediaType))\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\treturn nil, fmt.Errorf(\"invalid output format configuration; wrong type for media type, expected string (e.g. text/html), got %T\", vvi)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn c, nil\n\t\t},\n\t}\n\n\tdecoder, err := mapstructure.NewDecoder(config)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif err = decoder.Decode(input); err != nil {","sourceCodeStart":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/output/config.go#L102-L138","documentation":"Raised in the output-format decode hook (output/config.go:120) when an output format's mediaType field names a media type that isn't registered. Hugo resolves the string (e.g. \"text/html\") against the site's configured media types via mediaTypes.GetByType; if there's no match, the output format cannot be wired to a MIME type and config decoding fails.","triggerScenarios":"Decoding [outputFormats] configuration where mediaType is a string not present in the (built-in plus [mediaTypes]-defined) media type set — including custom types used before being declared, or lookups happening in a context where the custom [mediaTypes] block wasn't merged.","commonSituations":"Typos like \"text/htm\" or \"application/josn\"; defining a custom output format with mediaType = \"application/x-foo\" without a matching [mediaTypes.'application/x-foo'] block; copying output-format snippets between sites without also copying the mediaTypes definition; suffix-style values (\"json\") where a full type/subtype is required.","solutions":["Declare the custom media type in [mediaTypes] before referencing it: add a [mediaTypes.'<type/subtype>'] block with its suffixes.","Fix typos — mediaType must exactly match a known type like text/html, application/json, text/calendar.","When copying an outputFormats definition from another project, copy its mediaTypes definition too.","Run 'hugo config' to inspect the effective mediaTypes list your build knows about."],"exampleFix":"# before\n[outputFormats.MyFeed]\nmediaType = \"application/x-myfeed\"\n\n# after\n[mediaTypes.'application/x-myfeed']\nsuffixes = [\"myfeed\"]\n\n[outputFormats.MyFeed]\nmediaType = \"application/x-myfeed\"","handlingStrategy":"validation","validationCode":"// Every mediaType named in outputFormats must exist in mediaTypes config\n[mediaTypes.'application/vnd.api+json']\n  suffixes = ['json']\n[outputFormats.api]\n  mediaType = 'application/vnd.api+json'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Define custom media types under `mediaTypes` before referencing them in `outputFormats`","Use exact full type strings (e.g. `text/html`, not `html`) — lookup is by the full type name","Run `hugo config` in CI to validate the output format/media type wiring"],"tags":["hugo","configuration","output-formats","media-types"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}