Repository: gohugoio/hugo (language: go)

Issue:
Term page with build options not handled correctory
This is essentially the same as #12055, but with build options instead of the draft flag.

This test (the file content part) fails:

```text
func TestFoo(t *testing.T) {
	t.Parallel()

	files := `
-- layouts/index.html --
|{{ len site.Taxonomies.tags }}|
-- content/p1.md --
---
title: p1
tags: [a]
---
-- content/tags/a/_index.md --
---
title: tag-a-title-override
build:
  render: never
  list: never
---

  `

	b := hugolib.Test(t, files)

	b.AssertFileContent("public/index.html", "|0|")
	b.AssertFileExists("public/tags/a/index.html", false)
}
```

To me, these should be equivalent:

content/tags/tag-a/_index.md

```text
+++
title = 'My Tag A'
draft = true
+++
```

```text
+++
title = 'My Tag A'
[build]
render = 'never'
list = 'never'
+++
```

In both cases (a) the page should not be published, and (b) the term should not be a member of the "tags" taxonomy object.


Discussion / hints:

Fix patch:
diff --git a/hugolib/content_map_page.go b/hugolib/content_map_page.go
index 35a2650a122..9994fb04f4e 100644
--- a/hugolib/content_map_page.go
+++ b/hugolib/content_map_page.go
@@ -1904,6 +1904,9 @@ func (m *pageMap) CreateSiteTaxonomies(ctx context.Context) error {
 
 				switch p.Kind() {
 				case kinds.KindTerm:
+					if !p.m.shouldList(true) {
+						return false, nil
+					}
 					taxonomy := m.s.taxonomies[viewName.plural]
 					if taxonomy == nil {
 						return true, fmt.Errorf("missing taxonomy: %s", viewName.plural)


Test patch:
diff --git a/hugolib/taxonomy_test.go b/hugolib/taxonomy_test.go
index 8c29b781e48..629db185a19 100644
--- a/hugolib/taxonomy_test.go
+++ b/hugolib/taxonomy_test.go
@@ -858,3 +858,30 @@ draft: true
 
 	b.AssertFileExists("public/tags/a/index.html", false)
 }
+
+func TestTermBuildNeverRenderNorList(t *testing.T) {
+	t.Parallel()
+
+	files := `
+-- layouts/index.html --
+|{{ len site.Taxonomies.tags }}|
+-- content/p1.md --
+---
+title: p1
+tags: [a]
+---
+-- content/tags/a/_index.md --
+---
+title: tag-a-title-override
+build:
+  render: never
+  list: never
+---
+
+  `
+
+	b := Test(t, files)
+
+	b.AssertFileExists("public/tags/a/index.html", false)
+	b.AssertFileContent("public/index.html", "|0|")
+}