gohugoio/hugo · error
no existing content directory configured for this project
Error message
no existing content directory configured for this project
What it means
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.
Source
Thrown at create/content.go:54
)
const (
// DefaultArchetypeTemplateTemplate is the template used in 'hugo new project'
// and the template we use as a fall back.
DefaultArchetypeTemplateTemplate = `---
title: "{{ replace .File.ContentBaseName "-" " " | title }}"
date: {{ .Date }}
draft: true
---
`
)
// NewContent creates a new content file in h (or a full bundle if the archetype is a directory)
// in targetPath.
func NewContent(h *hugolib.HugoSites, kind, targetPath string, force bool) error {
if _, err := h.BaseFs.Content.Fs.Stat(""); err != nil {
return errors.New("no existing content directory configured for this project")
}
cf := hugolib.NewContentFactory(h)
if kind == "" {
var err error
kind, err = cf.SectionFromFilename(targetPath)
if err != nil {
return err
}
}
b := &contentBuilder{
archeTypeFs: h.PathSpec.BaseFs.Archetypes.Fs,
sourceFs: h.PathSpec.Fs.Source,
ps: h.PathSpec,
h: h,
cf: cf,View on GitHub ↗ (pinned to 8a468df065)
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.
Example fix
# before hugo new content posts/first.md # Error: no existing content directory configured for this project # after mkdir content hugo new content posts/first.md
Defensive patterns
Strategy: validation
Validate before calling
dirs := conf.Configs.Base.C.CommonDirs
if _, err := os.Stat(filepath.Join(dirs.WorkingDir, "content")); os.IsNotExist(err) {
os.MkdirAll(filepath.Join(dirs.WorkingDir, "content"), 0o755)
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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`.
Related errors
- language %q not found
- unsupported format: %q
- target path "%s" exists but is not a directory
- failed to create workingDir: %w
- failed to create CPU profile: %w
AI-assisted analysis of gohugoio/hugo@8a468df065 (2026-07-31).
Data as JSON: /data/errors/a1f2d6b717b67c79.json.
Report an issue: GitHub ↗.