Backtestshugorun-20261005-133023#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.
Both patches make the same core fix: they add `draft: false` to the placeholder front matter in `CreateContentPlaceHolder`. Page front matter takes precedence over cascaded values, so this stops a cascaded `draft: true` from excluding the placeholder from the build. That exclusion is why the page lookup fails with the 'target path conflicts' error. Both therefore fix the reported root cause. Patch A also sets `BuildExpired` alongside the existing `BuildFuture` in the `new content` command. This closes the same class of failure for a cascaded `expiryDate`, mirroring how `publishDate` is already handled. It is small, low-risk and consistent with the existing code. On its own it is neutral, but it makes the fix more robust in the issue's own spirit. On tests, Patch A adds testscripts that drive the actual `hugo new content` CLI. They reproduce the user's exact `_index.md` front matter and both the bundle (`trip-to-puebla/index.md`) and single-file forms. They assert that the 'Content Placeholder' text is not left behind, and they add an archetype-directory multilingual bundle case under a draft cascade. Patch B adds one Go unit test that calls `create.NewContent` with the reporter's cascade. That test is valid and would fail before the fix, but it bypasses the command layer and covers fewer scenarios. Patch A's tests are closer to the reported workflow and broader, and its extra change is coherent and low-risk. A is somewhat better.
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
2h 50m
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
53vs 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..d28699863 100644@@ -54,7 +54,11 @@ Ensure you run this within the root directory of your project.`, return newUserError("path needs to be provided") } cfg := flagsToCfg(cd, nil)+ // The content placeholder may inherit publishDate or+ // expiryDate via cascade; make sure it's always built so we+ // can look it up. cfg.Set("BuildFuture", true)+ cfg.Set("BuildExpired", true) h, err := r.Hugo(cfg) if err != nil { return errhugolib/content_factory.goindex 36cb29e63..b362b1e5f 100644@@ -112,8 +112,11 @@ func (f ContentFactory) CreateContentPlaceHolder(filename string, force bool) (s // This will be overwritten later, just write a placeholder to get // the paths correct.+ // Set draft to false so a draft value cascaded from an ancestor section+ // does not exclude the placeholder from the build. placeholder := `--- title: "Content Placeholder"+draft: false build: render: never list: nevertestscripts/commands/new_content.txtindex f432c8ace..4f5919130 100644@@ -43,6 +43,39 @@ hugo new content P1.md ! hugo new content p1.md stderr 'the target path conflicts with existing content' +# Content in a section that cascades draft or expiryDate.++cd $WORK+hugo new project cascade-excluded+mkdir cascade-excluded/content/posts/drafts cascade-excluded/content/posts/expired+cp cascade-drafts-index.md cascade-excluded/content/posts/drafts/_index.md+cp cascade-expired-index.md cascade-excluded/content/posts/expired/_index.md+cd cascade-excluded+hugo new content posts/drafts/trip-to-puebla/index.md+grep 'title = .Trip [Tt]o Puebla.' content/posts/drafts/trip-to-puebla/index.md+! grep 'Content Placeholder' content/posts/drafts/trip-to-puebla/index.md+hugo new content posts/drafts/trip-to-oaxaca.md+grep 'title = .Trip [Tt]o Oaxaca.' content/posts/drafts/trip-to-oaxaca.md+hugo new content posts/expired/old-news.md+grep 'title = .Old News.' content/posts/expired/old-news.md++-- cascade-drafts-index.md --+---+title: Drafts+build:+ render: never+cascade:+ draft: true+ build:+ render: link+draft: true+---+-- cascade-expired-index.md --+---+title: Expired+cascade:+ expiryDate: 2000-01-01+--- -- hugo.toml -- disableKinds = ['home','rss','section','sitemap','taxonomy','term'] [frontmatter]testscripts/commands/new_content_archetypedir.txtindex ccd85c999..6e75b623c 100644@@ -5,6 +5,19 @@ grep 'Site Lang: en' content/post/first-post/index.md grep 'Site Lang: no' content/post/first-post/index.no.md grep 'A text file.' content/post/first-post/file.txt +# Content in a section that cascades draft.+mkdir content/drafts+cp drafts-index.md content/drafts/_index.md+hugo new content --kind mybundle drafts/second-post+grep 'Second Post' content/drafts/second-post/index.md+grep 'Site Lang: no' content/drafts/second-post/index.no.md++-- drafts-index.md --+---+title: Drafts+cascade:+ draft: true+--- -- hugo.toml -- baseURL = "http://example.org/" [languages]
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