{"record":{"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/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/create/content.go#L83-L119","documentation":"After resolving an extension, create.NewContent checks Conf.ContentTypes().IsContentFile(targetPath) (create/content.go:100; media/config.go:136). If the extension is not registered as a content/media type Hugo refuses to create it, returning this error rather than writing an unrecognised file.","triggerScenarios":"`hugo new posts/file.xyz` where .xyz is not a configured content format; using an extension that exists only as a non-content media type.","commonSituations":"Typo in the extension; using a custom markup extension without first registering it under mediaTypes and the relevant markup config.","solutions":["Use a built-in content extension: .md, .mdown, .html, .htm, .org, .ad, .asciidoc, .rst.","If you need a custom extension, register it under [mediaTypes] and configure the matching markup/markup-extensions before running hugo new."],"exampleFix":"# before\n$ hugo new posts/note.xyz\n\n# after\n$ hugo new posts/note.md","handlingStrategy":"validation","validationCode":"// Reject unknown content extensions before calling NewContent.\nfunc ValidateContentExt(contentTypes media.ContentTypes, targetPath string) error {\n    if !contentTypes.IsContentFile(targetPath) {\n        return fmt.Errorf(\"%q is not a known content format\", targetPath)\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"if err := create.NewContent(h, kind, targetPath, force); err != nil {\n    return err\n}","preventionTips":["Use built-in content extensions (.md/.html/.org/.ad/.rst).","Register custom mediaTypes/markup before using a custom extension.","Double-check for extension typos in CLI commands and scripts."],"tags":["content","media-types","cli"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}