Repository: gohugoio/hugo (language: go)

Issue:
Unable to render weighted pages by term when taxonomy has space in name
#### config

```text
[taxonomies]
"book author" = "book authors"
```

#### content

content/books/good-omens.md

```text
---
title: Good Omens
book authors:
  - Neil Gaiman
  - Terry Pratchett
---
```

... and two others

#### template

```text
{{- $taxonomy := "book authors" }}
{{- range $term, $weightedPages := index site.Taxonomies "book authors" }}
  {{- $term }}|
  {{- range $weightedPages }}
    {{- .Title }}|
  {{- end }}
{{- end }}
```

#### results

v0.122.0 

```text
neil-gaiman|Coraline|Good Omens|terry-pratchett|Dodger|Good Omens|
```

v0.123.0-DEV-a80c3021 --> nothing rendered

#### example

```text
git clone --single-branch -b hugo-github-issue-12001 https://github.com/jmooring/hugo-testing hugo-github-issue-12001
cd hugo-github-issue-12001
hugo && cat public/index.html 
```



Discussion / hints:
I found this in an old test case, but a quick search found this:
<https://discourse.gohugo.io/t/multi-word-taxonomies-how-to-use-in-partial/27522>

I know it's uncommon.

Fix patch:
diff --git a/hugolib/content_map_page.go b/hugolib/content_map_page.go
index 570e45bd4ae..75863acbd8a 100644
--- a/hugolib/content_map_page.go
+++ b/hugolib/content_map_page.go
@@ -1859,13 +1859,12 @@ func (m *pageMap) CreateSiteTaxonomies(ctx context.Context) error {
 			LockType: doctree.LockTypeRead,
 			Handle: func(s string, n contentNodeI, match doctree.DimensionFlag) (bool, error) {
 				p := n.(*pageState)
-				plural := p.Section()
 
 				switch p.Kind() {
 				case kinds.KindTerm:
-					taxonomy := m.s.taxonomies[plural]
+					taxonomy := m.s.taxonomies[viewName.plural]
 					if taxonomy == nil {
-						return true, fmt.Errorf("missing taxonomy: %s", plural)
+						return true, fmt.Errorf("missing taxonomy: %s", viewName.plural)
 					}
 					k := strings.ToLower(p.m.term)
 					err := m.treeTaxonomyEntries.WalkPrefix(


Test patch:
diff --git a/hugolib/taxonomy_test.go b/hugolib/taxonomy_test.go
index 0db3e9c3910..913f4c21daf 100644
--- a/hugolib/taxonomy_test.go
+++ b/hugolib/taxonomy_test.go
@@ -753,3 +753,26 @@ Single.
 `
 	Test(t, files)
 }
+
+func TestTaxonomiesSpaceInName(t *testing.T) {
+	t.Parallel()
+
+	files := `
+-- hugo.toml --
+[taxonomies]
+authors = 'book authors'
+-- content/p1.md --
+---
+title: Good Omens
+book authors:
+  - Neil Gaiman
+  - Terry Pratchett
+---
+-- layouts/index.html --
+{{- $taxonomy := "book authors" }}
+Len Book Authors: {{ len (index .Site.Taxonomies $taxonomy) }}
+`
+	b := Test(t, files)
+
+	b.AssertFileContent("public/index.html", "Len Book Authors: 2")
+}