gohugoio/hugo · warning
no page found for ; the target path conflicts with existing…
Error message
no page found for %q; the target path conflicts with existing content
What it means
errTargetConflict (create/content.go:279) is returned by applyArcheType and buildFile when Hugo's GetContentPage returns nil for the target filename, meaning the path already maps to existing content or collides with a page/bundle. Creating would clobber or shadow existing content, so Hugo aborts (unless force was passed).
Solutions
- Pass --force to overwrite the existing file/bundle.
- Pick a different target path that does not collide.
- Remove or rename the conflicting existing file/bundle first.
- Check for an _index.md in the same section that is claiming the path.
Example fix
# before $ hugo new posts/hello.md # already exists -> conflict # after $ hugo new posts/hello.md --force
Defensive patterns
Strategy: validation
Validate before calling
// Detect a path conflict before calling NewContent.
func ResolveConflict(fs afero.Fs, targetPath string) (bool, error) {
_, err := fs.Stat(targetPath)
if err == nil { return true, nil }
if os.IsNotExist(err) { return false, nil }
return false, err
} Try / catch
err := create.NewContent(h, kind, targetPath, force)
if err != nil && strings.Contains(err.Error(), "conflicts with existing content") {
// decide: overwrite, rename, or abort
err = create.NewContent(h, kind, targetPath, true /* force */)
} Prevention
- Check whether the target path already exists before running hugo new.
- Use --force only when you intend to overwrite.
- Avoid scaffolding into paths occupied by an existing bundle.
When it happens
Trigger: `hugo new posts/existing.md` when posts/existing.md already exists; creating a leaf bundle whose path collides with an existing page; re-running a new-content command for a path already scaffolded; a path conflict with an _index.md-based section.
Common situations: Re-running hugo new after a previous (possibly failed) run; creating content at a path that overlaps an existing bundle directory.
Related errors
- content source: failed to convert %T to string
- ContentMediaType not set
- error building site
- error processing file
- failed to convert content for file
AI-assisted analysis of gohugoio/hugo@52c9bd7908 (2026-08-09).
Data as JSON: /api/errors/5cf718d3a00bbba3.
Report an issue: GitHub.
Appendix: 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 52c9bd7908)