diff --git a/hugolib/pagecollections.go b/hugolib/pagecollections.go index 4b0064252..01a194ac1 100644 --- a/hugolib/pagecollections.go +++ b/hugolib/pagecollections.go @@ -466,14 +466,6 @@ func (c *PageCollections) createWorkAllPages() error { } } - tmp := bucket.pages[:0] - for _, x := range bucket.pages { - if c.pagesMap.s.shouldBuild(x) { - tmp = append(tmp, x) - } - } - bucket.pages = tmp - if bucket.isEmpty() { if bucket.owner.IsSection() && bucket.owner.File().IsZero() { // Check for any nested section. diff --git a/hugolib/pages_map.go b/hugolib/pages_map.go index 26bbedec6..c7a74c4c1 100644 --- a/hugolib/pages_map.go +++ b/hugolib/pages_map.go @@ -100,6 +100,17 @@ func (m *pagesMap) initPageMetaFor(prefix string, bucket *pagesMapBucket) error } } } + + // Now that the metadata is initialized (with dates, draft set etc.) + // we can remove the pages that we for some reason should not include + // in this build. + tmp := bucket.pages[:0] + for _, x := range bucket.pages { + if m.s.shouldBuild(x) { + tmp = append(tmp, x) + } + } + bucket.pages = tmp } return nil diff --git a/hugolib/taxonomy_test.go b/hugolib/taxonomy_test.go index ccad3a207..294e4f1a0 100644 --- a/hugolib/taxonomy_test.go +++ b/hugolib/taxonomy_test.go @@ -320,3 +320,35 @@ Content. b.AssertFileContent("public/tags/index.html", `