{"record":{"id":"f0bec5f6f63afd96","repo":"gohugoio/hugo","slug":"media-type-q-not-found","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/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/output/config.go#L102-L138","documentation":"Thrown in the mapstructure decode hook (output/config.go:120) when a custom output format's 'mediaType' string does not match any media type registered in Hugo's media.Types. Hugo looks up the type with mediaTypes.GetByType(vviv) and, on miss, returns this error. The mediaType must be a fully-qualified type/subtype (e.g. text/html) that exists in the [mediaTypes] config or the built-in defaults.","triggerScenarios":"Defining [outputFormats.X] with mediaType = \"text/myformat\" without a corresponding [mediaTypes.\"text/myformat\"]; a typo like mediaType = \"text/html\" vs \"text/html;\" with stray characters; referencing a media type that was removed in a Hugo version upgrade.","commonSituations":"Adding a custom output format and forgetting to also add the matching [mediaTypes] entry; renaming a media type; upgrading Hugo where a previously built-in media type was dropped; copy-paste typos in the mediaType string.","solutions":["Add the missing [mediaTypes.\"text/myformat\"] section with suffixes and delimiter before referencing it in outputFormats.","Verify the string exactly matches the registered type/subtype (case-insensitive, no stray spaces/semicolons).","Use a built-in media type (text/html, application/json, application/rss+xml, etc.) if a custom one is not needed.","Run hugo config to list resolved mediaTypes and confirm the value exists."],"exampleFix":"# before (referenced but undefined)\n[outputFormats.MYFORMAT]\nmediaType = \"text/myformat\"\n\n# after (define the media type)\n[mediaTypes.\"text/myformat\"]\nsuffixes = [\"myfmt\"]\n[outputFormats.MYFORMAT]\nmediaType = \"text/myformat\"","handlingStrategy":"validation","validationCode":"// Confirm a mediaType string exists before referencing it in outputFormats.\nfunc mediaTypeExists(types media.Types, mt string) bool {\n    _, found := types.GetByType(mt)\n    return found\n}","typeGuard":"// A valid mediaType reference is a non-empty string matching a registered type.\nfunc isValidMediaTypeRef(v any, types media.Types) bool {\n    s, ok := v.(string)\n    if !ok { return false }\n    _, found := types.GetByType(s)\n    return found\n}","tryCatchPattern":"if _, found := mediaTypes.GetByType(mt); !found {\n    return fmt.Errorf(\"define [mediaTypes.%q] first\", mt)\n}","preventionTips":["Always pair a custom outputFormat with its [mediaTypes] definition.","Reuse built-in media types when possible.","Cross-check with `hugo config` to list resolved mediaTypes."],"tags":["media-types","output-formats","config","hugo"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}