]> git.maquefel.me Git - brevno-suite/hugo/commitdiff
Fix taxonomy kind template lookup issue
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Thu, 7 Mar 2024 07:25:34 +0000 (08:25 +0100)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Thu, 7 Mar 2024 08:50:50 +0000 (09:50 +0100)
Fixes #12193

hugolib/page__new.go
hugolib/taxonomy_test.go

index 9dd2f2cdfa9b96b95424bb7bc80755112ffeb454..e14de692549a2a6f2a2417dbf30138e13dbfbfbe 100644 (file)
@@ -145,9 +145,11 @@ func (h *HugoSites) newPage(m *pageMeta) (*pageState, *paths.Path, error) {
                                        // Either a taxonomy or a term.
                                        if tc.pluralTreeKey == m.Path() {
                                                m.pageConfig.Kind = kinds.KindTaxonomy
+                                               m.singular = tc.singular
                                        } else {
                                                m.pageConfig.Kind = kinds.KindTerm
                                                m.term = m.pathInfo.Unnormalized().BaseNameNoIdentifier()
+                                               m.singular = tc.singular
                                        }
                                }
                        } else if m.f != nil {
index 5a48df3b7cf6f344f12b6a2896279942a4ed05f4..e8bf547589d9c229ec2fe8bc0b44bdf1a6b36723 100644 (file)
@@ -911,3 +911,28 @@ title: tag-a-title-override
 
        b.AssertFileContent("public/tags/a/index.html", "Tag: tag-a-title-override|")
 }
+
+func TestTaxonomyLookupIssue12193(t *testing.T) {
+       t.Parallel()
+
+       files := `
+-- hugo.toml --
+disableKinds = ['page','rss','section','sitemap']
+[taxonomies]
+author = 'authors'
+-- layouts/_default/list.html --
+{{ .Title }}|
+-- layouts/_default/author.terms.html --
+layouts/_default/author.terms.html
+-- content/authors/_index.md --
+---
+title: Authors Page
+---
+`
+
+       b := Test(t, files)
+
+       b.AssertFileExists("public/index.html", true)
+       b.AssertFileExists("public/authors/index.html", true)
+       b.AssertFileContent("public/authors/index.html", "layouts/_default/author.terms.html") // failing test
+}