From 499794d19e306b490676306a89fc43668bfe1c4f Mon Sep 17 00:00:00 2001 From: sjh9714 <163989462+sjh9714@users.noreply.github.com> Date: Sat, 4 Jul 2026 00:37:13 +0900 Subject: [PATCH] create: Keep new content placeholders buildable Fixes #15078 --- create/content_test.go | 31 +++++++++++++++++++++++++++++++ hugolib/content_factory.go | 1 + 2 files changed, 32 insertions(+) diff --git a/create/content_test.go b/create/content_test.go index deafaed09..c8c3c1cdd 100644 --- a/create/content_test.go +++ b/create/content_test.go @@ -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 error diff --git a/hugolib/content_factory.go b/hugolib/content_factory.go index 36cb29e63..6757c64e3 100644 --- a/hugolib/content_factory.go +++ b/hugolib/content_factory.go @@ -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