{"id":"57c312e0494634ca","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":"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/8a468df065a75c1c7cf9f6850f32148746590ea5/resources/page/pagemeta/page_frontmatter.go#L492-L528","documentation":"Raised by `ResourceConfig.Compile` in resources/page/pagemeta/page_frontmatter.go when a page resource declares `content.mediaType` in front matter but that type is not registered in Hugo's media type table (`mediaTypes.GetByType`). Hugo needs a resolved media type to know how to treat the inline content, so it fails the build rather than guessing. The lookup accepts a full type string (e.g. `text/markdown`) or a registered suffix alias.","triggerScenarios":"Defining a page resource in front matter via `resources:` with `content: {mediaType: \"...\", value: \"...\"}` where the mediaType string is misspelled, uses a vendor type Hugo does not ship, or is a bare extension like `md` rather than `text/markdown`; also hit from `hugolib` page-builder tests that construct ResourceConfig programmatically.","commonSituations":"Config mistakes such as `mediaType: markdown` or `text/mardown`; relying on a custom type declared under `[mediaTypes]` in a config file that isn't loaded for the active environment/module; upgrading Hugo after a media-type rename so an older front matter value no longer resolves.","solutions":["Correct the `content.mediaType` value in the page's front matter to a full registered type string, e.g. `text/markdown` or `text/html`.","Run `hugo config mediatypes` (or `hugo config`) to list every registered type and copy the exact string.","If you need a custom type, register it under `[mediaTypes.\"your/type\"]` in hugo.toml with a `suffixes` entry, and confirm it's in the config for the environment you're building.","Verify the custom type isn't defined only in a module/theme config that is excluded by your current `--environment` or module mounts."],"exampleFix":"# before — hugo.toml page front matter\nresources:\n  - name: intro\n    content:\n      mediaType: markdown\n      value: \"# Hello\"\n\n# after\nresources:\n  - name: intro\n    content:\n      mediaType: text/markdown\n      value: \"# Hello\"","handlingStrategy":"validation","validationCode":"// verify media type is registered before referencing it in front matter config\nif _, found := conf.MediaTypes.GetByType(\"text/custom\"); !found {\n    return fmt.Errorf(\"media type not registered; add it under [mediaTypes] in site config\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only reference media types declared under [mediaTypes] in the site config or Hugo's built-in list","Check spelling of the type string (main/sub form, e.g. text/html)","Add custom media types to config before using them in content adapters or front matter"],"tags":["hugo","media-type","front-matter","config","page-resources"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}