After upgrading to v0.123.x, Hugo seems to be using anchorize rather than urlize when creating urls for term pages.
Given the following categories:
Things & Other things
Best & Worst of Times
Articles & News
This & That
Hugo v0.119.0 generates the following relative URLs
/categories/articles-news/
/categories/best-worst-of-times/
/categories/things-other-things/
/categories/this-that/
However v0.123.6 generates the following (note the extra double hyphens in place of &):
/categories/articles--news/
/categories/best--worst-of-times/
/categories/things--other-things/
/categories/this--that/
Reproduction:
git clone --single-branch -b anchorized-category-urls https://github.com/alanbreck/hugo-testing anchorized-category-urls
cd anchorized-category-urls
rm -rf public && hugo
This is expected/by design (I think).
Ok. This will result in broken URLs. The two options I can think of are:
- Accept the change and implement 301 redirects
- Add content files for each existing category which specifies a URL.
Is there another option that Iβm not thinking of, though?
Either 301 redirects server-side, or generate content pages (as needed) with βaliasesβ in front matter. I guess on some sites it could affect every term, but on most sites itβs probably a subset.
Hang on a second. I misunderstood what was happening here.
This affects more than terms:
content/
βββ posts/
βββ The Second & Third Waves.md <-- front matter: tags: [Concept & Prototypes]
v0.122.0
public/
βββ posts/
β βββ the-second-third-waves/
β β βββ index.html
β βββ index.html
βββ tags/
β βββ concept-prototypes/
β β βββ index.html
β βββ index.html
βββ index.html
v0.123.6
public/
βββ posts/
β βββ the-second--third-waves/ # URL has changed
β β βββ index.html
β βββ index.html
βββ tags/
β βββ concept--prototypes/ # URL has changed
β β βββ index.html
β βββ index.html
βββ index.html
@bep Please confirm that this (see my previous comment) was an intentional change. It probably doesnβt affect that many URLs in the wild, but redirects are required.
If intentional, one concern I have is that it wasnβt very apparent that this was changed. I didnβt notice until diffing the build folders.
I havenβt upgraded yet. I havenβt had time to finish diffing the output folders to find all cases of the above, and other discrepancies.
Understood. Thanks for following up, @jmooring.
I may just be missing it, but itβs not apparent to me from looking at Preserve triple hyphens etc. in URLs. Β· Issue #10104 Β· gohugoio/hugo Β· GitHub that this behavior would extend to other characters (like &). Could this behavior be documented (maybe on the Content Management/Taxonomies page with examples of which characters result in an extra hyphen, and which do not (e.g. a .)?
Related to the issue of understanding what the precise behavior will be, does it use anchorize or urlize under the hood? At first glance, it appears that it does not since hyphens are added for whitespace, but . is preserved.
Please create an issue in the docs repository. I think this should be about Page.RelPermalink and Page.Permalinkβ¦ what weβre talking about in this issue is not specific to taxonomy or term pages. The revised documentation should describe the relationship between the contentβs file path (or logical path when the content is not backed by a file) and the published URL.
Iβve created https://github.com/gohugoio/hugoDocs/issues/2487.
Also note https://github.com/gohugoio/hugoDocs/issues/2307. The concepts referenced/described in the affected pages need to consolidated. Itβs a bit of a mess right now, so Iβd like to limit the proposed docs change to the Permalink/RelPermalink pages. #2307 is a few days of work, so itβs not going to happen tomorrow.
Thank you so much for creating that issue, and for maintaining the docs, @jmooring!