Skip to content

Always strip taxonomy name prefix from term name #13423

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion hugolib/page__new.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func (h *HugoSites) doNewPage(m *pageMeta) (*pageState, *paths.Path, error) {
}
m.singular = tc.singular
if m.pageConfig.Kind == kinds.KindTerm {
m.term = paths.TrimLeading(strings.TrimPrefix(m.pathInfo.Unnormalized().Base(), tc.pluralTreeKey))
m.term = paths.TrimLeading(strings.TrimPrefix(m.pathInfo.Unnormalized().Base(), "/"+tc.plural))
}
}

Expand Down
22 changes: 22 additions & 0 deletions hugolib/page_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1968,3 +1968,25 @@ Title: {{ .Title }}
"deprecated: path in front matter was deprecated",
)
}

// See #13422
func TestPageTermWithSpaceInTaxonomyName(t *testing.T) {
t.Parallel()
files := `
-- hugo.toml --
[taxonomies]
"book author" = "book authors"
-- content/p1.md --
---
title: "p1"
kind: "page"
lang: "en"
path: "mypath"
book authors: ["Author One"]
---
-- layouts/_default/term.html --
{{ .Data.Term }}
`
b := Test(t, files, TestOptWarn())
b.AssertFileContent("public/book-authors/author-one/index.html", "Author One")
}