{"record":{"id":"f97b8300d5d14d82","repo":"gohugoio/hugo","slug":"failed-to-resolve-media-type-for-suffix-q","errorCode":null,"errorMessage":"failed to resolve media type for suffix %q","messagePattern":"failed to resolve media type for suffix %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"resources/page/pagemeta/page_frontmatter.go","lineNumber":412,"sourceCode":"\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 pages 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\tp.Path = paths.NormalizePathStringBasic(p.Path)\n\n\treturn p.resolveContentType(\"\", mediaTypes)\n}\n\nfunc (p *PageConfigEarly) resolveContentType(ext string, mediaTypes media.Types) error {\n\tif p.Content.Markup == \"\" && p.Content.MediaType == \"\" {\n\t\tif ext == \"\" {\n\t\t\text = \"md\"\n\t\t}\n\t\tp.ContentMediaType = MarkupToMediaType(ext, mediaTypes)\n\t\tif p.ContentMediaType.IsZero() {\n\t\t\treturn fmt.Errorf(\"failed to resolve media type for suffix %q\", ext)\n\t\t}\n\t}\n\n\tvar s string\n\tif p.ContentMediaType.IsZero() {\n\t\tif p.Content.MediaType != \"\" {\n\t\t\ts = p.Content.MediaType\n\t\t\tp.ContentMediaType, _ = mediaTypes.GetByType(s)\n\t\t}\n\n\t\tif p.ContentMediaType.IsZero() && p.Content.Markup != \"\" {\n\t\t\ts = p.Content.Markup\n\t\t\tp.ContentMediaType = MarkupToMediaType(s, mediaTypes)\n\t\t}\n\t}\n\n\tif p.ContentMediaType.IsZero() {\n\t\treturn fmt.Errorf(\"failed to resolve media type for %q\", s)","sourceCodeStart":394,"sourceCodeEnd":430,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/resources/page/pagemeta/page_frontmatter.go#L394-L430","documentation":"Thrown by resolveContentType when neither markup nor mediaType is set in content config, so Hugo falls back to the file extension and calls MarkupToMediaType(ext). If no registered media type matches that suffix (the returned type IsZero), the extension is unknown to Hugo.","triggerScenarios":"A content file with an extension Hugo does not recognize (e.g. '.adoc' when asciidoc isn't configured, or a custom '.foo'), or a content adapter whose path has an unknown extension and no markup/mediaType override.","commonSituations":"Adding a new markup format without registering its media type under [mediaTypes], or renaming content files to non-standard extensions. Common after enabling a new content format or in monorepo setups with unusual extensions.","solutions":["Register the media type for that suffix in your config under [mediaTypes].","Rename the content file to a known extension (md, html, org, etc.).","Set the 'markup' or 'mediaType' explicitly in front matter / page config to bypass suffix detection."],"exampleFix":"# before: content/myfile.foo\n# after (hugo.toml)\n[mediaTypes.\"text/asciidoc\"]\nsuffixes = [\"adoc\", \"asciidoc\"]","handlingStrategy":"validation","validationCode":"ext := strings.TrimPrefix(filepath.Ext(filename), \".\")\nif mt := pagemeta.MarkupToMediaType(ext, mediaTypes); mt.IsZero() {\n    return fmt.Errorf(\"no media type for extension %q\", ext)\n}","typeGuard":null,"tryCatchPattern":"if err := pcfg.SetMetaPreFromMap(ext, fm, logger, conf); err != nil {\n    return fmt.Errorf(\"content type for %s: %w\", filename, err)\n}","preventionTips":["Register custom media types under [mediaTypes] for non-standard extensions.","Set markup/mediaType in front matter to override extension detection.","Keep content files on standard extensions (md, html, org)."],"tags":["hugo","media-type","markup","content","configuration"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}