{"record":{"id":"a403500b7a365138","repo":"gohugoio/hugo","slug":"contentmediatype-not-set","errorCode":null,"errorMessage":"ContentMediaType not set","messagePattern":"ContentMediaType not set","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"hugolib/page.go","lineNumber":807,"sourceCode":"\n// wrapError adds some more context to the given error if possible/needed\nfunc (ps *pageState) wrapError(err error) error {\n\treturn ps.m.wrapError(err, ps.s.h.SourceFs)\n}\n\nfunc (ps *pageState) getPageInfoForError() string {\n\ts := fmt.Sprintf(\"kind: %q, path: %q\", ps.Kind(), ps.Path())\n\tif ps.File() != nil {\n\t\ts += fmt.Sprintf(\", file: %q\", ps.File().Filename())\n\t}\n\treturn s\n}\n\nfunc (ps *pageState) getContentConverter() converter.Converter {\n\tvar err error\n\tps.contentConverterInit.Do(func() {\n\t\tif ps.m.pageConfigSource.ContentMediaType.IsZero() {\n\t\t\tpanic(\"ContentMediaType not set\")\n\t\t}\n\t\tmarkup := ps.m.pageConfigSource.ContentMediaType.SubType\n\n\t\tif markup == \"html\" {\n\t\t\t// Only reachable for shortcode inner content rendering; file-based\n\t\t\t// HTML pages are gated at initFrontMatter via security.allowContent.\n\t\t\tmarkup = \"markdown\"\n\t\t}\n\t\tps.contentConverter, err = ps.m.newContentConverter(ps, markup)\n\t})\n\n\tif err != nil {\n\t\tps.s.Log.Errorln(\"Failed to create content converter:\", err)\n\t}\n\treturn ps.contentConverter\n}\n\nfunc (ps *pageState) errorf(err error, format string, a ...any) error {","sourceCodeStart":789,"sourceCodeEnd":825,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/hugolib/page.go#L789-L825","documentation":"Panic in getContentConverter: the page's ContentMediaType is the zero value when the converter is lazily initialized. The content converter is chosen based on ContentMediaType.SubType (markup), so an unset media type means the page's markup/content type was never configured during page decode. This indicates a page that bypassed the normal config-merge that sets the content media type.","triggerScenarios":"A pageState whose pageConfigSource.ContentMediaType was never set (e.g. constructed manually, or a page kind/path that skipped the front-matter and markup resolution). Reaching getContentConverter before the page's media type is established. Usually an internal ordering/construction bug.","commonSituations":"Custom page kinds created programmatically without setting markup. A fork that builds pages without the standard config merge. A bug in headless-bundle or content-adapter page creation.","solutions":["Ensure pages set their markup/content media type (e.g. assign pageConfigSource.ContentMediaType before content conversion).","If hit on stock Hugo, report with the page path; it indicates a decode-path gap.","Upgrade Hugo to the current release.","For programmatic pages, set the markup explicitly in front matter (markup = 'markdown')."],"exampleFix":"{{/* content page missing markup resolution */}}\n<!-- ensure front matter declares markup -->\n+++\ntitle = 'Post'\nmarkup = 'markdown'\n+++","handlingStrategy":"validation","validationCode":"// Ensure pages declare markup so ContentMediaType is resolved.\n// Front matter: markup = 'markdown'  (or rely on defaultMarkup in config).\n// For programmatic pages, set pageConfigSource.ContentMediaType before content conversion.","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always set markup in front matter or site defaultMarkup.","Use standard page construction so config merge runs.","Report stock-Hugo reproducers upstream.","Upgrade Hugo."],"tags":["pages","content","markup","converter","panic","internal-invariant"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}