Backtestshugorun-20260922-141813#15078

Issue #15078 Merged fix PR # Run 22 Sep 2026 · run-20260922-141813 gohugoio/hugo

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

Worse

The merged fix was judged better than our patch.

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

The production fix is byte-for-byte identical in both patches: adding `draft: false` to the placeholder front matter in hugolib/content_factory.go. This defeats the cascade (`cascade.draft: true` from posts/drafts/_index.md), which was overriding the placeholder to draft:true and causing 'no page found ... conflicts with existing content'. So correctness, scope of the production change, and root-cause handling are a tie. The decision rests on test quality. Patch B adds a focused unit test (TestNewContentWithBuildCascade) in create/content_test.go that reuses the file's existing helpers (initFs, newTestCfg, testconfig.GetTestConfigs, readFileFromFs, and *qt.C which satisfies testing.TB), calls the function under test create.NewContent directly, and reproduces the issue's exact front matter including `build.render: never` and top-level `draft: true`. It fails before the fix (placeholder written) and passes after (real 'Trip to Puebla' content). It is idiomatic and consistent with neighboring tests. Patch A instead adds an integration testscript that deviates from the file's established inline-txtar convention and, more importantly, invokes `hugo new project issue-15078` — Hugo's scaffold subcommand is `hugo new site`, not `hugo new project` (Patch A's own next line correctly uses `hugo new content`), so that step likely fails as an unknown command, undermining confidence the test actually exercises the fix. Patch A also simplifies the reproducer, dropping `build.render: never` and the top-level `draft: true` from _index.md, making it a less faithful reproduction. Both patches touch exactly one test file plus the shared one-line prod change, so scope is equal; Patch B wins on a more reliable, idiomatic, and faithful test.

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

17m 48s43 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

21vs 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+21 −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..94919836e 100644@@ -43,6 +43,26 @@ hugo new content P1.md ! hugo new content p1.md stderr 'the target path conflicts with existing content' +# Issue 15078++cd $WORK+hugo new project issue-15078+cd issue-15078+mkdir content/posts/drafts+cp $WORK/drafts-index.md content/posts/drafts/_index.md+hugo new content posts/drafts/trip-to-puebla/index.md+exists content/posts/drafts/trip-to-puebla/index.md+grep 'Trip to Puebla' content/posts/drafts/trip-to-puebla/index.md+! grep 'Content Placeholder' content/posts/drafts/trip-to-puebla/index.md++-- drafts-index.md --+---+title: Drafts+cascade:+  draft: true+  build:+    render: link+--- -- hugo.toml -- disableKinds = ['home','rss','section','sitemap','taxonomy','term'] [frontmatter] 
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

The working tree is clean and minimal: only my two intended changes plus the pre-existing AGENTS.md/CLAUDE.md deletions (present in the starting snapshot, unrelated to this fix). commands/new.go has no net change. Done.

Summary

What was wrong

hugo new content posts/drafts/trip-to-puebla/index.md failed with a false no page found for "…"; the target path conflicts with existing content error and left only a "Content Placeholder" file — but only when the target sat under a section whose branch-bundle _index.md had cascade: {draft: true}.

hugo new content writes a temporary placeholder content file, runs an internal non-draft build to resolve the page object (so the archetype can be applied), then overwrites the placeholder with the rendered archetype. The parent section's cascade: {draft: true} was marking the placeholder page as a draft; the non-draft build dropped it (content_map_page_assembler.go → site.shouldBuild), so HugoSites.GetContentPage returned nil and create/content.go reported the false conflict. Paths not under a draft cascade (e.g. posts/2026/07/foo/index.md) were unaffected — matching the report exactly.

What I changed

  • hugolib/content_factory.go — added a single draft: false line to the placeholder front matter in CreateContentPlaceHolder. A page's own front-matter value takes precedence over an inherited cascade value (verified in hugolib/page__meta.go: front matter fills pageConfig.Params first; cascade only fills keys not already present), so the transient placeholder is no longer treated as a draft and survives the internal build. The placeholder is immediately overwritten by the applied archetype, so draft: false never persists to the user's file.
  • testscripts/commands/new_content.txt — added an "Issue 15078" regression scenario (+ a -- drafts-index.md -- block) that creates a section with cascade: draft:true, runs hugo new content under it, and asserts the real archetype output (Trip to Puebla) is present and Content Placeholder is not.

I intentionally did not enable a global BuildDrafts for this build (my first attempt did, and it broke the existing Issue 12786 scenario, which relies on a real draft leaf-bundle being dropped to detect a resource conflict). The surgical placeholder change preserves that behavior.

Test evidence

  • Regression test failed before the fix with the exact reported error (no page found … the target path conflicts with existing content).
  • After the fix: TestCommands/new_content passes (all scenarios: 12599, 12602, 12786, 14112, 15078, archetypedir), and the full create package (TestNewContentFromFile/*, TestNewContentFromDirSiteFunction) passes — confirming no regression in the shared placeholder path.
  • Reviewer confirmed the diff is minimal, matches the report, and cannot persist draft: false to user content.

Requirements checklist

  1. Fix the false "target path conflicts" error under a draft: true cascade — implemented + tested (regression test fails before / passes after).
  2. Behavior identical whether target is trip-to-puebla/index.md or trip-to-puebla — same code path (buildFile); the fix targets the shared placeholder, so both forms are covered. Not separately scripted, but the mechanism is path-form-independent.
  3. Non-drafts case (posts/2026/07/foo/index.md) must keep working — preserved; no cascade means no draft, and create tests + other new_content scenarios pass.
  4. Don't break existing conflict detection (12602 dir conflict, 12786 leaf-bundle resource conflict, 14112 case collision) — verified; all pass, and I explicitly avoided the global-BuildDrafts approach that broke 12786.

All changes left uncommitted in the working tree.