{"id":"f19b2e1daf8c4950","repo":"gohugoio/hugo","slug":"target-path-q-is-not-a-known-content-format","errorCode":null,"errorMessage":"target path %q is not a known content format","messagePattern":"target path %q is not a known content format","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"create/content.go","lineNumber":101,"sourceCode":"\twithBuildLock := func() (string, error) {\n\t\tif !h.Configs.Base.NoBuildLock {\n\t\t\tunlock, err := h.BaseFs.LockBuild()\n\t\t\tif err != nil {\n\t\t\t\treturn \"\", fmt.Errorf(\"failed to acquire a build lock: %s\", err)\n\t\t\t}\n\t\t\tdefer unlock()\n\t\t}\n\n\t\tif b.isDir {\n\t\t\treturn \"\", b.buildDir()\n\t\t}\n\n\t\tif ext == \"\" {\n\t\t\treturn \"\", fmt.Errorf(\"failed to resolve %q to an archetype template\", targetPath)\n\t\t}\n\n\t\tif !h.Conf.ContentTypes().IsContentFile(b.targetPath) {\n\t\t\treturn \"\", fmt.Errorf(\"target path %q is not a known content format\", b.targetPath)\n\t\t}\n\n\t\treturn b.buildFile()\n\t}\n\n\tfilename, err := withBuildLock()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif filename != \"\" {\n\t\treturn b.openInEditorIfConfigured(filename)\n\t}\n\n\treturn nil\n}\n\ntype contentBuilder struct {","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/create/content.go#L83-L119","documentation":"After confirming the target has an extension, create.NewContent checks the configured content formats (h.Conf.ContentTypes().IsContentFile) to ensure the target path's extension is a recognized content format (md, html, adoc, org, rst, pandoc, etc.). An unknown extension means Hugo would not treat the created file as content, so it refuses to create it.","triggerScenarios":"`hugo new content <path>` where the path's extension is not registered as a content media type — e.g. `hugo new posts/data.txt` or `hugo new notes/x.markdonw` (typo). Only reached for single-file (non-directory-archetype) creation.","commonSituations":"Typos in the extension (.mdown vs configured formats, .mdx which Hugo doesn't support natively); trying to create data or asset files with `hugo new content` instead of placing them in data/ or assets/; custom mediaTypes/contentTypes config that removed or renamed a format.","solutions":["Use a supported content extension, typically `.md`: `hugo new content posts/x.md`.","If you use a custom format, register it under `contentTypes`/`mediaTypes` in your site config so IsContentFile recognizes the extension.","For non-content files (data, assets), create them directly in the appropriate directory instead of via `hugo new`."],"exampleFix":"# before\nhugo new content posts/notes.txt\n# Error: target path \"posts/notes.txt\" is not a known content format\n\n# after\nhugo new content posts/notes.md","handlingStrategy":"validation","validationCode":"ext := strings.TrimPrefix(filepath.Ext(targetPath), \".\")\nvalid := map[string]bool{\"md\": true, \"html\": true, \"adoc\": true, \"org\": true, \"rst\": true, \"pandoc\": true}\nif !valid[ext] { return fmt.Errorf(\"unsupported content extension %q\", ext) }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always give hugo new targets a content extension (.md, .html, .adoc, ...)","Don't pass directory paths or extensionless names to hugo new","Validate user-supplied filenames against Hugo's content formats before invoking"],"tags":["hugo","content-format","media-types","cli","config"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}