{"id":"5cf718d3a00bbba3","repo":"gohugoio/hugo","slug":"no-page-found-for-q-the-target-path-conflicts-wi","errorCode":null,"errorMessage":"no page found for %q; the target path conflicts with existing content","messagePattern":"no page found for %q; the target path conflicts with existing content","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"create/content.go","lineNumber":280,"sourceCode":"\n\tif b.kind != \"\" {\n\t\tpathsToCheck = append(pathsToCheck, b.kind+ext)\n\t}\n\n\tpathsToCheck = append(pathsToCheck, \"default\"+ext)\n\n\tfor _, p := range pathsToCheck {\n\t\tfi, err := b.archeTypeFs.Stat(p)\n\t\tif err == nil {\n\t\t\tb.archetypeFi = fi.(hugofs.FileMetaInfo)\n\t\t\tb.isDir = fi.IsDir()\n\t\t\treturn\n\t\t}\n\t}\n}\n\nfunc errTargetConflict(path string) error {\n\treturn fmt.Errorf(\"no page found for %q; the target path conflicts with existing content\", path)\n}\n\nfunc (b *contentBuilder) applyArcheType(contentFilename string, archetypeFi hugofs.FileMetaInfo) error {\n\tp := b.h.GetContentPage(contentFilename)\n\tif p == nil {\n\t\treturn errTargetConflict(contentFilename)\n\t}\n\n\tf, err := b.sourceFs.Create(contentFilename)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer f.Close()\n\n\tif archetypeFi == nil {\n\t\treturn b.cf.ApplyArchetypeTemplate(f, p, b.kind, DefaultArchetypeTemplateTemplate)\n\t}\n","sourceCodeStart":262,"sourceCodeEnd":298,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/create/content.go#L262-L298","documentation":"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.","triggerScenarios":"`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.","commonSituations":"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.","solutions":["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.","If you're intentionally recreating an existing file, pass `--force` (works only for the plain file-exists case, not the directory/URL conflict).","Remove or rename the conflicting directory/bundle if it's obsolete.","Check module mounts and per-language content dirs for another source claiming the same target path."],"exampleFix":"# before — content/posts/foo/ (bundle) already exists\nhugo new content posts/foo.md\n# Error: no page found for \"...\"; the target path conflicts with existing content\n\n# after — create inside or beside the bundle\nhugo new content posts/foo-part-two.md","handlingStrategy":"validation","validationCode":"target := filepath.Join(\"content\", \"posts\", \"my-post.md\")\nif _, err := os.Stat(target); err == nil {\n    return fmt.Errorf(\"%s already exists; use --force or pick another path\", target)\n}\n// also check for a sibling bundle: posts/my-post/index.md","typeGuard":null,"tryCatchPattern":"err := create.NewContent(h, kind, path, force)\nif err != nil && strings.Contains(err.Error(), \"conflicts with existing content\") {\n    // choose a different path or remove the conflicting page/bundle\n}","preventionTips":["Check for an existing file or leaf bundle at the target path before hugo new","Don't create both content/foo.md and content/foo/index.md","Use --force deliberately, never as a default flag in scripts"],"tags":["hugo","content","bundle","path-conflict","cli"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}