gohugoio / hugo

The world’s fastest framework for building websites.
https://gohugo.io
Apache License 2.0
73.49k stars 7.37k forks source link

Taxonomy terms with single quote in the term name and custom metadata duplicates #12606

Closed nikdoof closed 1 week ago

nikdoof commented 1 week ago

Please excuse the title, as I can't think of a better way to explain this issue in a single line.

On my site, I have a specific taxonomy that has single quotes in the term name, e.g. "Disney's Riviera Resort". If I define custom metadata/content for this term then the customised version will render, but also a non-customised version linking to the same pageRef.

Removing the custom metadata returns the term to a 'working' state.

Steps to Reproduce

  1. Create a new site with a default theme
  2. Create a taxonomy in hugo.toml
  3. Create a page using that taxonomy, with a tag with a "'" in it (e.g. Disney's, which is urlized to "disneys")
  4. Check taxonomy/disneys page and see it rendering correctly
  5. Create a custom metadata taxonomy/disneys/_index.md with a title the same as the current name, add content or metadata
  6. Check taxonomy/tag page and see multiple entries have rendered.

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

$ Hugo version
hugo v0.127.0-74e0f3bd63c51f3c7a0f07a7c779eec9e922957e+extended darwin/arm64 BuildDate=2024-06-05T10:27:59Z VendorInfo=gohugoio

Does this issue reproduce with the latest release?

Yes

nikdoof commented 1 week ago

Possibly related to #12191, The suggested workaround in this issue of using the term without " or ' and then override the title within the metadata does seem to work, but changes of the title/metadata do not seem to be detected correctly during hugo serve and result in dead/duplicate pages being rendered, restarting hugo serve resolves it.

Here is a demo repo for the issue: https://github.com/nikdoof/hugo-12606

jmooring commented 1 week ago

I have not yet dug into the details above, but I wrote this tips & tricks post a few months ago, prompted by the release of v0.123.0:

https://discourse.gohugo.io/t/limit-use-of-punctuation-within-taxonomy-terms/48638

There's an open issue to add this information to the documentation: https://github.com/gohugoio/hugoDocs/issues/2465

jmooring commented 1 week ago

I created a minimal example per your description above:

git clone --single-branch -b hugo-github-issue-12606 https://github.com/jmooring/hugo-testing hugo-github-issue-12606
cd hugo-github-issue-12606
hugo --printPathWarnings

The terminal displays this warning...

WARN Duplicate target paths: /tags/disneys-riviera-resort/index.html (2)

...which is expected per the tips & tricks post that I referred to in my previous comment.

To handle this correctly:

content/posts/post-1.md ```text +++ title = 'Post 1' tags = ["Disneys Riviera Resort"] # disallowed punctuation removed +++ ```
content/tags/disneys-riviera-resort/_index.md ```text +++ title = "Disney's Riviera Resort" # add punctuation as needed +++ ```
jmooring commented 1 week ago

@nikdoof I'm going to close this. The documentation update will be addressed in https://github.com/gohugoio/hugoDocs/issues/2465.