-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
Double-hyphens in post URLs reduce to single-hyphens; regression introduced in v0.50 causes links to break #7288
Comments
No, I think this is how it has been behaving for several years. |
Indeed, this change happened about 1.5 years back in https://github.com/gohugoio/hugo/releases/tag/v0.50 . Sincere request to allow users to retain their hyphens where they need them. I only landed up on this today as I was tracing through one of the old ox-hugo tests linked in old issues. |
Making the best guess from the changelog.. Update: It's actually this: e421696d
|
@bep This can be made a non-breaking fix if the double-hyphens are retained at least when the user has explicitly set the permalinks option to use the [permalinks]
"/" = "/:filename/" Right now, even with this option set, when the file name is Thanks. |
This issue has been automatically marked as stale because it has not had recent activity. The resources of the Hugo team are limited, and so we are asking for your help. |
@bep Can you please look at this issue? This one issue is still bugging me. |
Improve handling of pre-existing hyphens in input to UnicodeSanitize. This commit accomplishes three things: 1. Explicitly allow hyphens 2. Avoid appending a hyphen if a preceeding hyphen is found 3. Avoid prepending a hyphen if a trailing hyphen is found Fixes gohugoio#7288
Hugo does not allow 2 consecutive hyphens in slugs derived from Markdown file names and auto-converts 2-hyphens to single hyphens. Ref gohugoio/hugo#7288.
The documentation ( https://ox-hugo.scripter.co/doc/org-capture-setup/ ) suggests using `org-hugo-slug` to auto-generate the file name from the title. This change is so that the auto-generated file name doesn't have consecutive hyphens in its name. Otherwise the Hugo-generated URL will not match with the file name exactly. See gohugoio/hugo#7288. This change does not affect the generation of anchor names within a post as double-hyphens are OK there. This commit mainly affects the people using `org-hugo-slug` outside of ox-hugo, like in their Org Capture templates. Earlier the generated file name could have been "foo--bar.md". Now it would be "foo-bar.md" instead.
Improve handling of existing hyphens in input to UnicodeSanitize. This commit accomplishes three things: 1. Explicitly allow hyphens 2. Avoid appending a hyphen if a preceeding hyphen is found 3. Avoid prepending a hyphen if a trailing hyphen is found Fixes gohugoio#7288
Improve handling of existing hyphens in input to UnicodeSanitize. This commit accomplishes three things: 1. Explicitly allow hyphens 2. Avoid appending a hyphen if a preceeding hyphen is found 3. Avoid prepending a hyphen if a trailing hyphen is found Fixes #7288
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
What version of Hugo are you using (
hugo version
)?Does this issue reproduce with the latest release?
Yes
Expected behavior: If the content file is named
content/foo--bar.md
, the page URL is expected to be<site>/foo--bar/
.Observed behavior: If the content file is named
content/foo--bar.md
, the page URL becomes<site>/foo-bar/
(note that the double-hyphen becomes single-hyphen).I believe this regression was caused
after the switch to Goldmark.in e421696d.Recipe to reproduce this issue
git clone https://gitlab.com/hugo-mwe/double-hyphens-in-post-urls
(Content file: https://gitlab.com/hugo-mwe/double-hyphens-in-post-urls/-/blob/master/content/post--with--double--hyphens.md )cd double-hyphens-in-post-urls
Above demo site is also deployed at https://determined-leakey-137470.netlify.app/ .
Observed output
In
public/index.html
, we will see:Expected output
Same issue reported by other users
Seriousness of this regression
I have quite a few pages with double-hyphens.. Double hyphens are used as idea separator in URLs. Here are few examples:
I link to these pages for references, and now they break because now double-hyphens are auto-reduced to single-hyphens.
Can the number of hyphens specified by the user in the content file name be preserved?
The text was updated successfully, but these errors were encountered: