Backtestshugorun-20260917-015623#15078
New content command thinks there's a path conflict for a file that doesn't exist yet
Our patch was judged better than the merged fix.
In this judgment, Patch A = our agent, Patch B = the merged fix.
Root cause: `hugo new content` builds the site with a content-inclusion filter to locate the just-created placeholder page. The `_index.md` cascade sets `draft: true`, so the placeholder is filtered out of the build, the lookup fails, and Hugo emits the false 'target path conflicts with existing content' error (leaving only the placeholder). The existing code already sets `BuildFuture=true` in the `new content` config for exactly this class of problem — a newly created page must be discoverable regardless of publish state. Patch A extends that established convention by also setting `BuildDrafts` and `BuildExpired`, which is the principled, general root-cause fix: it makes the discovery build surface the target page whether cascade/archetype marks it draft, future, or expired. Its testscript reproduces the issue's exact cascade+draft scenario and would fail before / pass after. Patch B instead pins `draft: false` into the placeholder front matter, relying on page-front-matter-beating-cascade precedence. That does fix the reported (draft-only) case and its Go test is valid, and it is admirably minimal — but it is narrower (leaves expired cascade unaddressed) and is more of a targeted neutralization than the general mechanism the codebase already uses via BuildFuture. Patch A's real weakness is scope: its second hunk adds ~16 lines of unrelated leaf-bundle conflict-detection logic that the issue never asks for, adds filesystem reads, and could introduce new false-conflict behavior; a maintainer would likely strip it. That is a genuine strike under the scope criterion. However, correctness is weighted first, and Patch A's core fix is the more robust, convention-consistent root-cause resolution (the second hunk is inert for the index.md test path and does not compromise the fix or the reproduction). On balance A edges B.
The judge saw only the two patches, labelled A and B in random order, with issue links and version numbers removed. The reasoning above is shown verbatim.
Solve
43m 39s2 turns
Wall-clock time in the container
Full test suite
No new failures
3,667 passed · 93 skipped · 3,773 total
Contamination audit
Unknown
See the audit notes for this run
Patch size
44vs 32 merged
Changed lines, ours vs merged
The issue
View on GitHubI run my personal blog using Hugo for about two years ago, and it has been great!, but there have been issues with how I create pages.
I have section called posts/drafts/ where I create drafts for posts before I move them to a posts/YEAR/MONTH directory where I can post them. The bug happens when I create the page for a post, like this:
<pre>
hugo new content posts/drafts/trip-to-puebla/index.md
</pre>
Running this command with the debug flag returns the following:
<pre>
INFO build: step process substep collect files 138 files_total 138 pagesources_total 71 resourcesources_total 67 duration 37.1674ms
INFO build: step process duration 38.2639ms
INFO build: step assemble duration 2.064063s
INFO build: step render pages 0 content 0 duration 548.6µs
INFO build: step render deferred count 0 duration 0s
INFO build: step postProcess duration 0s
INFO build: duration 2.1061069s
ERROR no page found for "C:\\...\\Documents\\projects\\kfcmanwebsite2\\content\\posts\\drafts\\trip-to-puebla\\index.md"; the target path conflicts with existing conten
</pre>
What's funny is that a page _is_ created, but it's a placeholder page that looks like this:
---
title: "Content Placeholder"
build:
render: never
list: never
publishResources: false
---
After consulting with ChatGPT (yes you can stone me now) and testing some things here's another stuff that cursed AI and I found:
- The name of the page still causes some issues, doesn't matter if its
trip-to-puebla/index.mdortrip-to-puebla. - Renaming the
draftsdirectory and rerunning the command with the new name still throws the error - This issue does not happen if I run it when creating something like
hugo new content posts/2026/07/foo/index.md
One final thing, I have a branch bundle on posts/drafts/_index.md that has the following front matter:
title: Drafts
build:
render: never
cascade:
draft: true
build:
render: link
weight: 9999
draft: true
This is so any of the pages inside posts/drafts don't get published.
What version of Hugo are you using (hugo version)?
<pre>
hugo v0.163.3-4d22555aebf458d5d150500c9ac4bee5b24cf0d3+extended windows/amd64 BuildDate=2026-06-18T16:18:24Z VendorInfo=gohugoio
</pre>
Does this issue reproduce with the latest release?
I'm using the latest version, so it _should_ be reproducible. I think. The repo for my hugo project can be found here, though it may be a little heavy.
The two patches
commands/new.goindex e82258a79..d99357921 100644@@ -55,6 +55,8 @@ Ensure you run this within the root directory of your project.`, } cfg := flagsToCfg(cd, nil) cfg.Set("BuildFuture", true)+ cfg.Set("BuildExpired", true)+ cfg.Set("BuildDrafts", true) h, err := r.Hugo(cfg) if err != nil { return errcreate/content.goindex 91a7f9462..21bdd9834 100644@@ -244,6 +244,22 @@ func (b *contentBuilder) buildFile() (string, error) { return "", errTargetConflict(contentPlaceholderAbsFilename) } + // If the target is a non-index content file placed inside an existing leaf+ // bundle (a directory that already contains an index.* content file), it+ // would become a page resource rather than a standalone page, conflicting+ // with the existing bundle.+ if !b.h.Conf.ContentTypes().IsIndexContentFile(contentPlaceholderAbsFilename) {+ parentDir := filepath.Dir(contentPlaceholderAbsFilename)+ if entries, derr := afero.ReadDir(b.sourceFs, parentDir); derr == nil {+ for _, e := range entries {+ name := e.Name()+ if !e.IsDir() && strings.HasPrefix(name, "index.") && b.h.Conf.ContentTypes().IsContentFile(name) {+ return "", errTargetConflict(contentPlaceholderAbsFilename)+ }+ }+ }+ }+ if err := b.h.Build(hugolib.BuildCfg{NoBuildLock: true, SkipRender: true, ContentInclusionFilter: contentInclusionFilter}); err != nil { return "", err }testscripts/commands/new_content.txtindex f432c8ace..061b32776 100644@@ -43,6 +43,15 @@ hugo new content P1.md ! hugo new content p1.md stderr 'the target path conflicts with existing content' +# Issue 15078: new content under a section whose cascade sets draft:true must not report a false path conflict.++cd $WORK+cd issue-15078+hugo new content posts/drafts/trip-to-puebla/index.md+stdout 'Content .* created'+grep 'draft = true' content/posts/drafts/trip-to-puebla/index.md+! grep 'Content Placeholder' content/posts/drafts/trip-to-puebla/index.md+ -- hugo.toml -- disableKinds = ['home','rss','section','sitemap','taxonomy','term'] [frontmatter]@@ -52,3 +61,22 @@ publishDate = [':filename', ':default'] DATE _{{ .Date.Format "2006-01-02" }}_ SLUG _{{ .Slug }}_ TITLE _{{ .Title }}_+-- issue-15078/hugo.toml --+title = "Issue 15078"+-- issue-15078/archetypes/default.md --+++++title = '{{ replace .File.ContentBaseName "-" " " | title }}'+draft = true+++++-- issue-15078/content/posts/drafts/_index.md --+---+title: Drafts+build:+ render: never+cascade:+ draft: true+ build:+ render: link+weight: 9999+draft: true+---
create/content_test.goindex deafaed09..c8c3c1cdd 100644@@ -159,6 +159,37 @@ site RegularPages: {{ len site.RegularPages }} cContains(c, readFileFromFs(t, fs.Source, filepath.Join("content", "mypage.md")), `draft: true`) } +// See issue 15078.+func TestNewContentWithBuildCascade(t *testing.T) {+ t.Parallel()++ mm := afero.NewMemMapFs()+ c := qt.New(t)++ c.Assert(initFs(mm), qt.IsNil)+ c.Assert(mm.MkdirAll(filepath.Join("content", "posts", "drafts"), 0o755), qt.IsNil)+ c.Assert(afero.WriteFile(mm, filepath.Join("content", "posts", "drafts", "_index.md"), []byte(`---+title: Drafts+build:+ render: never+cascade:+ draft: true+ build:+ render: link+draft: true+---+`), 0o755), qt.IsNil)++ cfg, fs := newTestCfg(c, mm)+ conf := testconfig.GetTestConfigs(fs.Source, cfg)+ h, err := hugolib.NewHugoSites(deps.DepsCfg{Configs: conf, Fs: fs})+ c.Assert(err, qt.IsNil)++ const target = "posts/drafts/trip-to-puebla/index.md"+ c.Assert(create.NewContent(h, "", target, false), qt.IsNil)+ c.Assert(readFileFromFs(c, fs.Source, filepath.Join("content", target)), qt.Contains, `title: "Trip to Puebla"`)+}+ func initFs(fs afero.Fs) error { perm := os.FileMode(0o755) var err errorhugolib/content_factory.goindex 36cb29e63..6757c64e3 100644@@ -114,6 +114,7 @@ func (f ContentFactory) CreateContentPlaceHolder(filename string, force bool) (s // the paths correct. placeholder := `--- title: "Content Placeholder"+draft: false build: render: never list: never
What the agent reported
Summary
What was wrong
hugo new content posts/drafts/trip-to-puebla/index.md failed with a false no page found ...; the target path conflicts with existing content error whenever the target section's branch bundle (posts/drafts/_index.md) had a cascade setting draft: true.
The command works by writing a temporary placeholder file, running an intermediate SkipRender build to resolve that file to a Page (so the archetype can be applied), then looking the page up via HugoSites.GetContentPage. The placeholder inherited draft: true from the section cascade; Site.shouldBuild returns false for drafts, so the page was added to droppedPages and deleted from the page tree. GetContentPage walks only the page tree, so it returned nil, and applyArcheType reported the bogus conflict — leaving the "Content Placeholder" file behind. commands/new.go already set BuildFuture for the same class of problem (issue #12599) but not drafts/expired.
What I changed (production, 2 files)
commands/new.go:58-59— alongside the existingcfg.Set("BuildFuture", true), addedcfg.Set("BuildExpired", true)andcfg.Set("BuildDrafts", true)so the transient path-resolution build no longer drops draft/expired pages. The written file is unaffected (the archetype is applied afterward;SkipRenderpublishes nothing).
create/content.go(buildFile) — enabling drafts meant a draft leaf bundle is no longer dropped, which had been the coincidental mechanism detecting the "create a file inside an existing leaf bundle" conflict (issue #12786). I added a draft-independent check: if the target is a non-index content file whose parent directory already contains anindex.*content file, return the conflict error. It is skipped when the target itself is an index file (so creating a new leaf bundle works) and matches onlyindex.(leaf), not_index.(branch), so normal pages in a section are unaffected.
Regression test (testscripts/commands/new_content.txt) — added an "Issue 15078" case reproducing the exact scenario (a posts/drafts/_index.md with cascade.draft: true), asserting the command now succeeds and the created file contains the archetype (draft = true), not the placeholder.
Test evidence
- Before the fix: the new case failed with
no page found for ".../trip-to-puebla/index.md"; the target path conflicts with existing content(confirmed test-first). - After the fix:
TestCommandsandTestCommands/new_contentPASS, with zero failures — including the pre-existing conflict cases (#12602, #12786, #14112), which all still correctly error. - The
create,hugolib, and roothugopackages all pass.
Note on other failures / working tree: A full-suite run showed failures in unrelated packages (codegen, internal/warpc WASM, resources/images golden-file tests, vendored tpl/internal/go_templates). These have no dependency on create/commands and are pre-existing environmental failures, not caused by this change. The AGENTS.md/CLAUDE.md deletions were already present in the working tree at session start (harness scaffolding); I did not touch them. All changes are left uncommitted.