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

v0.131.0 Permalinks tokens break previous behavior #12918

Closed
MichaelSasser opened this issue Oct 9, 2024 · 2 comments · Fixed by #12938
Closed

v0.131.0 Permalinks tokens break previous behavior #12918

MichaelSasser opened this issue Oct 9, 2024 · 2 comments · Fixed by #12938
Assignees
Labels
Milestone

Comments

@MichaelSasser
Copy link

MichaelSasser commented Oct 9, 2024

Permalinks tokens are extremely useful, and I had a couple of places, they would be beneficial. Tere is currently just one issue. They break most of my page.

Error: error building site: render: error expanding "/wiki/Foo:Bar_Baz": permalink ill-formed

Instead of running a full-blown wiki, we went with doing that in hugo. To get roughly the same behavior as Wikipedia would, I used the same URL style. This includes colons in the URL.

Since I couldn't find anything where I could transform the title into it, I added url to every wiki page like the following.

# without whitespace
title: "Help:Infobox"
url: "/wiki/Help:Infobox"

# with whitespace 
title: "Foo:Bar Baz"
url: "/wiki/Foo:Bar_Baz" 

# with whitespace but without colons 
title: "Foo Bar"
url: "/wiki/Foo_Bar" 

# without whitespace but without colons 
title: "Foo"
url: "/wiki/Foo" 

Because I was unable to find any workarounds and I consider the wiki URL to be a key feature, I can't upgrade to >= v0.131.0.

Would it be possible to add something like a raw url feature to hugo that behaves like url did prior to v0.131.0?
Alternatively, if that use case would be interesting for others, something like a :wikititle permalink token, that would replicate the behavior I'm looking for (e.g. do the same as :title would, but replace whitespace with underscores and keep the letter case)?

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

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

Does this issue reproduce with the latest release?

Yes

@bep
Copy link
Member

bep commented Oct 10, 2024

Error: error building site: render: error expanding "/wiki/Foo:Bar_Baz": permalink ill-formed

As I see it, there are (at least) 2 issues here:

  1. We should not not throw an error when we find tokens we don't know about.
  2. But even with that there would be potential ambiguity in your setup (e.g. /wiki/Foo:slug)

Hmm ...

I see 3 options ...

  1. New rawurl:
  2. Add a way to escape colons in url, e.g. url: "/wiki/Foo\:Bar_Baz"
  3. Add a new permalinks keyword, e.g. :wikititle.

I'm not a fan of 1) and we should probably do 2) even if we also do 3), so I guess we can start with that as a fix + improving the parsing and error message...

@MichaelSasser
Copy link
Author

LGTM

bep pushed a commit to n1xx1/contrib-hugo that referenced this issue Oct 15, 2024
bep added a commit to n1xx1/contrib-hugo that referenced this issue Oct 15, 2024
Mostly to get back to an attribute regexp that's reasonably simle to read/understand.

Updates gohugoio#12918
bep added a commit to n1xx1/contrib-hugo that referenced this issue Oct 15, 2024
Mostly to get back to an attribute regexp that's reasonably simle to read/understand.

Updates gohugoio#12918
bep added a commit to n1xx1/contrib-hugo that referenced this issue Oct 15, 2024
Mostly to get back to an attribute regexp that's reasonably simle to read/understand.

Updates gohugoio#12918
bep pushed a commit to n1xx1/contrib-hugo that referenced this issue Oct 15, 2024
bep added a commit to n1xx1/contrib-hugo that referenced this issue Oct 15, 2024
Mostly to get back to an attribute regexp that's reasonably simle to read/understand.

Updates gohugoio#12918
bep added a commit that referenced this issue Oct 15, 2024
Mostly to get back to an attribute regexp that's reasonably simle to read/understand.

Updates #12918
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants