{"record":{"id":"57c312e0494634ca","repo":"gohugoio/hugo","slug":"media-type-q-not-found-57c312","errorCode":null,"errorMessage":"media type %q not found","messagePattern":"media type %q not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"resources/page/pagemeta/page_frontmatter.go","lineNumber":510,"sourceCode":"\treturn nil\n}\n\nfunc (rc *ResourceConfig) Compile(basePath string, fim hugofs.FileMetaInfo, conf config.AllProvider, mediaTypes media.Types) error {\n\tif rc.Params != nil {\n\t\thmaps.PrepareParams(rc.Params)\n\t}\n\n\t// Note that NormalizePathStringBasic will make sure that we don't preserve the unnormalized path.\n\t// We do that when we create resources from the file system; mostly for backward compatibility,\n\t// but also because people tend to use the filename to name their resources (with spaces and all),\n\t// and this isn't relevant when creating resources from an API where it's easy to add textual meta data.\n\trc.Path = paths.NormalizePathStringBasic(path.Join(basePath, rc.Path))\n\trc.PathInfo = conf.PathParser().Parse(files.ComponentFolderContent, rc.Path)\n\tif rc.Content.MediaType != \"\" {\n\t\tvar found bool\n\t\trc.ContentMediaType, found = mediaTypes.GetByType(rc.Content.MediaType)\n\t\tif !found {\n\t\t\treturn fmt.Errorf(\"media type %q not found\", rc.Content.MediaType)\n\t\t}\n\t}\n\n\tvar sitesMatrixFile sitesmatrix.VectorStore\n\tif fim != nil {\n\t\tsitesMatrixFile = fim.Meta().SitesMatrix\n\t}\n\n\trc.SitesMatrix = buildSitesMatrixFromSitesConfig(\n\t\tconf,\n\t\tsitesMatrixFile,\n\t\trc.Sites,\n\t)\n\n\trc.SitesComplements = buildSitesComplementsFromSitesConfig(\n\t\tconf,\n\t\tfim.Meta(),\n\t\trc.Sites,","sourceCodeStart":492,"sourceCodeEnd":528,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/resources/page/pagemeta/page_frontmatter.go#L492-L528","documentation":"Thrown by ResourceConfig.Compile when a page resource explicitly sets Content.MediaType but mediaTypes.GetByType returns found=false, meaning that media type string is not registered. This applies to resources (images, data files, etc.) declared in front matter / page resources, not the page content itself.","triggerScenarios":"A page resource in front matter sets 'mediaType: application/x-foo' where that type is not defined under [mediaTypes].","commonSituations":"Referencing a custom media type for a resource without registering it, or a typo in the mediaType value for a resource declaration.","solutions":["Register the media type under [mediaTypes] in your config.","Correct the mediaType string to a known registered type.","Omit mediaType and let Hugo infer it from the resource's file extension."],"exampleFix":"# before\n---\nresources:\n  - src: data.custom\n    mediaType: application/x-custom\n---\n# after (also add to config)\n[mediaTypes.\"application/x-custom\"]\nsuffixes = [\"custom\"]","handlingStrategy":"validation","validationCode":"if _, found := mediaTypes.GetByType(rc.Content.MediaType); rc.Content.MediaType != \"\" && !found {\n    return fmt.Errorf(\"media type %q not registered\", rc.Content.MediaType)\n}","typeGuard":null,"tryCatchPattern":"if err := rc.Compile(basePath, fim, conf, mediaTypes); err != nil {\n    return fmt.Errorf(\"resource compile: %w\", err)\n}","preventionTips":["Register custom media types under [mediaTypes] before using them for resources.","Prefer letting Hugo infer mediaType from the resource extension.","Validate mediaType strings against registered types."],"tags":["hugo","media-type","resources","front-matter","configuration"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}