diff options
author | Bjørn Erik Pedersen <[email protected]> | 2024-02-25 15:43:52 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2024-02-25 18:28:16 +0100 |
commit | f27e578718e9ec9a7a8dbbf23134852455f9a667 (patch) | |
tree | 0ba51ac3547f740e047f9bbcc4c4e7e9c8f60b60 | |
parent | d310595a2ba672fa30dc9a9a2679542cfc919a35 (diff) | |
download | hugo-f27e578718e9ec9a7a8dbbf23134852455f9a667.tar.gz hugo-f27e578718e9ec9a7a8dbbf23134852455f9a667.zip |
Fix term template lookup when its backed by a content file
Closes #12146
-rw-r--r-- | hugolib/content_map_page.go | 6 | ||||
-rw-r--r-- | hugolib/taxonomy_test.go | 26 |
2 files changed, 30 insertions, 2 deletions
diff --git a/hugolib/content_map_page.go b/hugolib/content_map_page.go index ba0c858fe..89df951e9 100644 --- a/hugolib/content_map_page.go +++ b/hugolib/content_map_page.go @@ -1552,8 +1552,10 @@ func (sa *sitePagesAssembler) assembleTermsAndTranslations() error { } pages.InsertIntoValuesDimension(pi.Base(), n) term = pages.Get(pi.Base()) - } else if term.(*pageState).m.term != v { - term.(*pageState).m.term = v + } else { + m := term.(*pageState).m + m.term = v + m.singular = viewName.singular } if s == "" { diff --git a/hugolib/taxonomy_test.go b/hugolib/taxonomy_test.go index 629db185a..5a48df3b7 100644 --- a/hugolib/taxonomy_test.go +++ b/hugolib/taxonomy_test.go @@ -885,3 +885,29 @@ build: b.AssertFileExists("public/tags/a/index.html", false) b.AssertFileContent("public/index.html", "|0|") } + +func TestTaxonomiesTermLookup(t *testing.T) { + t.Parallel() + + files := ` +-- hugo.toml -- +baseURL = "https://example.com" +[taxonomies] +tag = "tags" +-- content/_index.md -- +--- +title: "Home" +tags: ["a", "b"] +--- +-- layouts/taxonomy/tag.html -- +Tag: {{ .Title }}| +-- content/tags/a/_index.md -- +--- +title: tag-a-title-override +--- +` + + b := Test(t, files) + + b.AssertFileContent("public/tags/a/index.html", "Tag: tag-a-title-override|") +} |