Skip to content

Commit

Permalink
Fix term template lookup when its backed by a content file
Browse files Browse the repository at this point in the history
Closes #12146
  • Loading branch information
bep committed Feb 25, 2024
1 parent d310595 commit f27e578
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
6 changes: 4 additions & 2 deletions hugolib/content_map_page.go
Expand Up @@ -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 == "" {
Expand Down
26 changes: 26 additions & 0 deletions hugolib/taxonomy_test.go
Expand Up @@ -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|")
}

0 comments on commit f27e578

Please sign in to comment.