From fc6aabe9380017fab34105f9aed4c408c57e98ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Sat, 17 Feb 2024 15:17:13 +0100 Subject: [PATCH] Fix handling of draft term pages By just removing the term page and all of its page entries. Fixes #12055 --- hugolib/content_map_page.go | 6 ++++-- hugolib/taxonomy_test.go | 23 +++++++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/hugolib/content_map_page.go b/hugolib/content_map_page.go index 70e8a0bb6..d9cbddfba 100644 --- a/hugolib/content_map_page.go +++ b/hugolib/content_map_page.go @@ -1415,8 +1415,10 @@ func (sa *sitePagesAssembler) applyAggregatesToTaxonomiesAndTerms() error { if err := p.setMetaPost(cascade); err != nil { return false, err } - - if err := sa.pageMap.treeTaxonomyEntries.WalkPrefix( + if !p.s.shouldBuild(p) { + sa.pageMap.treePages.Delete(s) + sa.pageMap.treeTaxonomyEntries.DeletePrefix(paths.AddTrailingSlash(s)) + } else if err := sa.pageMap.treeTaxonomyEntries.WalkPrefix( doctree.LockTypeRead, paths.AddTrailingSlash(s), func(ss string, wn *weightedContentNode) (bool, error) { diff --git a/hugolib/taxonomy_test.go b/hugolib/taxonomy_test.go index 17e1b6cd4..8c29b781e 100644 --- a/hugolib/taxonomy_test.go +++ b/hugolib/taxonomy_test.go @@ -835,3 +835,26 @@ tags: ["hellO world"] b.AssertFileContent("public/tags/hello-world/index.html", "HellO World|term|tag|tags|hellO world|") } + +func TestTermDraft(t *testing.T) { + t.Parallel() + + files := ` +-- layouts/_default/list.html -- +|{{ .Title }}| +-- content/p1.md -- +--- +title: p1 +tags: [a] +--- +-- content/tags/a/_index.md -- +--- +title: tag-a-title-override +draft: true +--- + ` + + b := Test(t, files) + + b.AssertFileExists("public/tags/a/index.html", false) +}