gohugoio/hugo · error

no page found for %q; the target path conflicts with existin

Error message

no page found for %q; the target path conflicts with existing content

What it means

Emitted by errTargetConflict, used in three places in the `hugo new` flow: when the content placeholder can't be created because a regular file already occupies the path, when a directory with the target's name (sans extension) exists so the new file would collide with an existing section or leaf bundle's URL, and when after the internal build no Page object exists for the created placeholder (meaning something else claims that path). In all cases Hugo refuses because the new content would conflict with existing content.

Source

Thrown at create/content.go:280

	if b.kind != "" {
		pathsToCheck = append(pathsToCheck, b.kind+ext)
	}

	pathsToCheck = append(pathsToCheck, "default"+ext)

	for _, p := range pathsToCheck {
		fi, err := b.archeTypeFs.Stat(p)
		if err == nil {
			b.archetypeFi = fi.(hugofs.FileMetaInfo)
			b.isDir = fi.IsDir()
			return
		}
	}
}

func errTargetConflict(path string) error {
	return fmt.Errorf("no page found for %q; the target path conflicts with existing content", path)
}

func (b *contentBuilder) applyArcheType(contentFilename string, archetypeFi hugofs.FileMetaInfo) error {
	p := b.h.GetContentPage(contentFilename)
	if p == nil {
		return errTargetConflict(contentFilename)
	}

	f, err := b.sourceFs.Create(contentFilename)
	if err != nil {
		return err
	}
	defer f.Close()

	if archetypeFi == nil {
		return b.cf.ApplyArchetypeTemplate(f, p, b.kind, DefaultArchetypeTemplateTemplate)
	}

View on GitHub ↗ (pinned to 8a468df065)

Solutions

  1. Pick a non-conflicting path, or put the content inside the existing bundle: edit content/posts/foo/index.md instead of creating posts/foo.md.
  2. If you're intentionally recreating an existing file, pass `--force` (works only for the plain file-exists case, not the directory/URL conflict).
  3. Remove or rename the conflicting directory/bundle if it's obsolete.
  4. Check module mounts and per-language content dirs for another source claiming the same target path.

Example fix

# before — content/posts/foo/ (bundle) already exists
hugo new content posts/foo.md
# Error: no page found for "..."; the target path conflicts with existing content

# after — create inside or beside the bundle
hugo new content posts/foo-part-two.md
Defensive patterns

Strategy: validation

Validate before calling

target := filepath.Join("content", "posts", "my-post.md")
if _, err := os.Stat(target); err == nil {
    return fmt.Errorf("%s already exists; use --force or pick another path", target)
}
// also check for a sibling bundle: posts/my-post/index.md

Try / catch

err := create.NewContent(h, kind, path, force)
if err != nil && strings.Contains(err.Error(), "conflicts with existing content") {
    // choose a different path or remove the conflicting page/bundle
}

Prevention

When it happens

Trigger: `hugo new content posts/foo.md` when content/posts/foo/ already exists as a directory (section or bundle) — the file's URL would collide; or the placeholder file exists and creation failed without --force; or hugolib.GetContentPage returns nil for the placeholder after the SkipRender build because another page (e.g. an index bundle or a mount) shadows that path.

Common situations: Creating `posts/foo.md` when a leaf bundle `posts/foo/index.md` (or branch `posts/foo/_index.md`) already exists; re-running `hugo new` for an existing file without --force; module mounts or multilingual content dirs shadowing the target path.

Related errors


AI-assisted analysis of gohugoio/hugo@8a468df065 (2026-07-31). Data as JSON: /data/errors/5cf718d3a00bbba3.json. Report an issue: GitHub ↗.