Skip to content
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

Term name includes plural taxonomy name as prefix #13422

Open
jasonccox opened this issue Feb 20, 2025 · 0 comments · May be fixed by #13423
Open

Term name includes plural taxonomy name as prefix #13422

jasonccox opened this issue Feb 20, 2025 · 0 comments · May be fixed by #13423

Comments

@jasonccox
Copy link

When a taxonomy name includes a space, its terms which only have a single associated page have the plural taxonomy name prepended to their name when rendering.

This bug appears to have been introduced in #13064.

Setup

hugo.toml:

[taxonomies]
"book author" = "book authors"

content/posts/post1.md:

---
title: My Post
tags: ["Tag One"]
book authors: ["Author One"]
---

content/posts/post2.md:

---
title: My Post
tags: ["Tag One", "Tag Two"]
book authors: ["Author One", "Author Two"]
---

layouts/_default/taxonomy.html

{{ range .Data.Terms.ByCount }}
Term: {{ .Term }}
Count: {{ .Count }}
Name: {{ .Name }}
Page title: {{ .Page.Title }}

{{ end }}

Expected output in public/book-authors/index.html

Term: author one
Count: 2
Name: author one
Page title: Author One

Term: author two
Count: 1
Name: author two
Page title: Author Two

Actual output in public/book-authors/index.html

Term: author one
Count: 2
Name: author one
Page title: Author One

Term: book authors/author two
Count: 1
Name: book authors/author two
Page title: Book Authors/Author Two

What version of Hugo are you using (hugo version)?

$ hugo version
hugo v0.144.2+extended+withdeploy linux/amd64 BuildDate=unknown

Does this issue reproduce with the latest release?

Yes

jasonccox added a commit to jasonccox/hugo that referenced this issue Feb 20, 2025
If the taxonomy name differs when normalized versus unnormalized (e.g.,
because it has a space in it which is converted to a dash when
normalized), the plural tree key will not match as a prefix to the
term's base path (which is normalized). Use the non-normalized taxonomy
name instead to ensure that the prefix always matches and is trimmed.

Fixes: gohugoio#13422
Signed-off-by: Jason Cox <[email protected]>
@jasonccox jasonccox linked a pull request Feb 20, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant