{"record":{"id":"a1f2d6b717b67c79","repo":"gohugoio/hugo","slug":"no-existing-content-directory-configured-for-this","errorCode":null,"errorMessage":"no existing content directory configured for this project","messagePattern":"no existing content directory configured for this project","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"create/content.go","lineNumber":54,"sourceCode":")\n\nconst (\n\t// DefaultArchetypeTemplateTemplate is the template used in 'hugo new project'\n\t// and the template we use as a fall back.\n\tDefaultArchetypeTemplateTemplate = `---\ntitle: \"{{ replace .File.ContentBaseName \"-\" \" \" | title }}\"\ndate: {{ .Date }}\ndraft: true\n---\n\n`\n)\n\n// NewContent creates a new content file in h (or a full bundle if the archetype is a directory)\n// in targetPath.\nfunc NewContent(h *hugolib.HugoSites, kind, targetPath string, force bool) error {\n\tif _, err := h.BaseFs.Content.Fs.Stat(\"\"); err != nil {\n\t\treturn errors.New(\"no existing content directory configured for this project\")\n\t}\n\n\tcf := hugolib.NewContentFactory(h)\n\n\tif kind == \"\" {\n\t\tvar err error\n\t\tkind, err = cf.SectionFromFilename(targetPath)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tb := &contentBuilder{\n\t\tarcheTypeFs: h.PathSpec.BaseFs.Archetypes.Fs,\n\t\tsourceFs:    h.PathSpec.Fs.Source,\n\t\tps:          h.PathSpec,\n\t\th:           h,\n\t\tcf:          cf,","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/create/content.go#L36-L72","documentation":"NewContent (the `hugo new` content path) stats the content filesystem root; if that stat fails, no content directory is mounted for the project and the command aborts. This happens when the content/ directory is absent or when module mounts remap content to a path that does not exist.","triggerScenarios":"`hugo new posts/x.md` when there is no content/ directory, or when a custom module mount points the content source at a missing path.","commonSituations":"A project where content/ was deleted; a mounts config that overrode the default content dir with a nonexistent target; running hugo new in a non-site directory.","solutions":["Create the content directory: `mkdir -p content`.","Fix the module `mounts` so a content directory is actually mounted and exists.","If starting fresh, scaffold the site with `hugo new site` first."],"exampleFix":"// before\nhugo new posts/hello.md   # no content dir\n// after\nmkdir -p content\nhugo new posts/hello.md","handlingStrategy":"validation","validationCode":"// Verify the content directory exists before hugo new\nif _, err := os.Stat(filepath.Join(workDir, \"content\")); os.IsNotExist(err) {\n    if mkErr := os.MkdirAll(filepath.Join(workDir, \"content\"), 0o755); mkErr != nil {\n        return mkErr\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep a content/ directory in every site project.","If using custom mounts, ensure the mounted content source path exists.","Scaffold sites with `hugo new site` so content/ is created."],"tags":["hugo","content","cli","filesystem"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}