{"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":"exception","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/8a468df065a75c1c7cf9f6850f32148746590ea5/create/content.go#L36-L72","documentation":"Returned by create.NewContent (the `hugo new content` path) when a Stat of the root of the project's content filesystem fails. Hugo refuses to create content because there is no usable content directory mounted for the project, so it has nowhere to place the new file.","triggerScenarios":"Running `hugo new content ...` (or anything calling create.NewContent) when h.BaseFs.Content.Fs.Stat(\"\") errors — i.e. no content dir exists on disk and no content mounts are configured, or the configured contentDir/module mount points to a missing path.","commonSituations":"Running `hugo new` outside a Hugo site root or in a freshly cloned repo whose content/ directory isn't checked in (empty dirs aren't tracked by git); a custom `contentDir` in config pointing to a nonexistent path; module mounts for content misconfigured; running from the wrong working directory or forgetting `-s`/`--source`.","solutions":["Create the content directory: `mkdir content` in the site root (or the path your `contentDir` setting names).","Confirm you are running the command from the site root (or pass `--source <path>`).","Check `contentDir` and any `[[module.mounts]]` with target 'content' in your config point at existing directories.","If this is a brand-new project, run `hugo new site .` first to scaffold the structure."],"exampleFix":"# before\nhugo new content posts/first.md\n# Error: no existing content directory configured for this project\n\n# after\nmkdir content\nhugo new content posts/first.md","handlingStrategy":"validation","validationCode":"dirs := conf.Configs.Base.C.CommonDirs\nif _, err := os.Stat(filepath.Join(dirs.WorkingDir, \"content\")); os.IsNotExist(err) {\n    os.MkdirAll(filepath.Join(dirs.WorkingDir, \"content\"), 0o755)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Create the content/ directory (or configured contentDir) before running hugo new","Check contentDir in config matches the actual directory on disk","Run hugo new from the site root, not a subdirectory","Scaffold sites with hugo new site to get the standard layout"],"tags":["hugo","cli","content","filesystem","config"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}