Backtestshugorun-20260930-140149#15078

Issue #15078 Merged fix PR # Run 30 Sep 2026 · run-20260930-140149 gohugoio/hugo

New content command thinks there's a path conflict for a file that doesn't exist yet

Better

Our patch was judged better than the merged fix.

In this judgment, Patch B = our agent, Patch A = the merged fix.

Both patches make the same production change: they add `draft: false` to the placeholder front matter in `CreateContentPlaceHolder`. This stops the section's `cascade: draft: true` from marking the temporary placeholder as a draft, which is what excluded it from the build and caused the 'no page found / conflicts with existing content' error. Correctness is therefore identical, and the comparison comes down to tests.

Patch A adds a Go unit test in `create/content_test.go` that reproduces the drafts section with the cascade. It then asserts on `title: "Trip to Puebla"` in YAML form. Whether that holds depends on the archetypes that `initFs` sets up, so the assertion is fragile and may not match the actual archetype output format. It covers only the leaf-bundle `index.md` case.

Patch B adds a testscript that runs the real `hugo new content` command end to end in a fresh project. It uses the user's exact `_index.md` front matter, including `weight`. It covers both scenarios the issue mentions: the `trip-to-puebla/index.md` bundle and a plain `another-post.md` file. It also checks explicitly that the output is not the 'Content Placeholder' and that the archetype-derived title is present. This matches the issue's CLI reproduction more closely, tests the specific symptom (the placeholder being left behind), and would clearly fail before the fix.

Scope and craft are comparable. Patch B's test is broader and closer to the reported scenario, so B is the stronger patch.

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

33m 22s17 turns

Wall-clock time in the container

Full test suite

No new failures

3,671 passed · 93 skipped · 3,773 total

Contamination audit

Clean

No sign the agent saw the real fix

Patch size

29vs 32 merged

Changed lines, ours vs merged

I 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.md or trip-to-puebla.
  • Renaming the drafts directory 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

Our patch+29 −0
hugolib/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: nevertestscripts/commands/new_content.txtindex f432c8ace..3b30520e9 100644@@ -43,6 +43,22 @@ hugo new content P1.md ! hugo new content p1.md stderr 'the target path conflicts with existing content' +# Issue: new content under a draft section with cascade draft: true++cd $WORK+hugo new project drafts-cascade+mkdir drafts-cascade/content/posts/drafts+cp drafts-cascade-index.md drafts-cascade/content/posts/drafts/_index.md+cd drafts-cascade+hugo new content posts/drafts/trip-to-puebla/index.md+exists content/posts/drafts/trip-to-puebla/index.md+! grep 'Content Placeholder' content/posts/drafts/trip-to-puebla/index.md+grep 'title = .Trip to Puebla.' content/posts/drafts/trip-to-puebla/index.md+hugo new content posts/drafts/another-post.md+exists content/posts/drafts/another-post.md+! grep 'Content Placeholder' content/posts/drafts/another-post.md+grep 'title = .Another Post.' content/posts/drafts/another-post.md+ -- hugo.toml -- disableKinds = ['home','rss','section','sitemap','taxonomy','term'] [frontmatter]@@ -52,3 +68,15 @@ publishDate = [':filename', ':default'] DATE _{{ .Date.Format "2006-01-02" }}_ SLUG _{{ .Slug }}_ TITLE _{{ .Title }}_+-- drafts-cascade-index.md --+---+title: Drafts+build:+    render: never+cascade:+    draft: true+    build:+        render: link+weight: 9999+draft: true+--- 
Merged fix · PR #+32 −0
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

hugo new content posts/drafts/trip-to-puebla/index.md now works under a section with cascade: draft: true: it writes the real archetype content instead of stopping with the "conflicts with existing content" error. The official ./bt-test gate never actually ran the tests, so all results below come from running go test directly.

What was wrong: Before building the page, hugo new content writes a temporary placeholder file (the "Content Placeholder" page you saw) and then looks that page up. That file said nothing about drafts, so your cascade: draft: true made it a draft. hugo new doesn't build drafts, so the placeholder was left out and the lookup found nothing. The error text calls that a path conflict, though no conflict existed, and the placeholder was left on disk.

What I changed:

  • hugolib/content_factory.go: the placeholder front matter now includes draft: false. A value the page sets itself overrides a cascaded one. The placeholder is always replaced by the archetype output, so this never shows up in your file; the final draft setting still comes from your archetype.
  • I first tried building drafts during hugo new instead. That broke an existing test (Issue 12786), where creating p1/p2.md next to an existing p1/index.md must be rejected. That check only works because the existing page is a draft and gets left out, so I dropped that approach.

Test evidence:

  • New test: I added a case to testscripts/commands/new_content.txt using your exact _index.md front matter. It runs hugo new content posts/drafts/trip-to-puebla/index.md and hugo new content posts/drafts/another-post.md, then checks that each file exists, no longer says "Content Placeholder", and has the archetype title.
  • Before the fix it failed with no page found for ".../trip-to-puebla/index.md"; the target path conflicts with existing content.
  • After the fix it passes, along with the rest of the new test scripts, including the existing conflict cases.
  • Why not ./bt-test: ./bt-test . -run TestCommands/new_content stopped during setup because it couldn't download Go modules (proxy.golang.org is unreachable here). I ran the tests with go test against the local module cache at /bt/cache/go-mod instead.
  • Other tests: ./create/... passes. TestCommands and ./hugolib/ each have failures, but it's the same module and git-info tests that need network access, with and without my change (checked by stashing it).
  • Review: an independent review found no blocking issues.

Your observations:

#What you reportedOutcome
1trip-to-puebla/index.md under posts/drafts fails with the conflict errorFixed; covered by the new test
2A "Content Placeholder" file is left behindFixed for this case; the test asserts the placeholder text is gone. If hugo new fails for another reason, the placeholder is still left behind (unchanged).
3Both the trip-to-puebla/index.md and trip-to-puebla forms failExplained, and fixed through the same cause. The test covers the index.md form and a single file (another-post.md); the bare trip-to-puebla form wasn't tested separately.
4Renaming drafts doesn't helpExplained: the cause is the cascaded draft: true, not the folder name
5posts/2026/07/foo/index.md worksExplained: there's no draft cascade there; draft already defaulted to false, so this path is unaffected

The same false error could still happen if a section cascades an expiry date that has passed; I left that alone as out of scope. The already-deleted AGENTS.md and CLAUDE.md were that way before I started and are untouched. Everything is left uncommitted.