Skip to content

Commit

Permalink
Fix taxonomy kind template lookup issue
Browse files Browse the repository at this point in the history
Fixes #12193
  • Loading branch information
bep committed Mar 7, 2024
1 parent 632ad74 commit 0567a3e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
2 changes: 2 additions & 0 deletions hugolib/page__new.go
Expand Up @@ -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 {
Expand Down
25 changes: 25 additions & 0 deletions hugolib/taxonomy_test.go
Expand Up @@ -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
}

0 comments on commit 0567a3e

Please sign in to comment.