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

Allow page-relative alias in front matter #5757

Closed
bep opened this issue Mar 17, 2019 · 6 comments · Fixed by #5802
Closed

Allow page-relative alias in front matter #5757

bep opened this issue Mar 17, 2019 · 6 comments · Fixed by #5802
Assignees
Milestone

Comments

@bep
Copy link
Member

bep commented Mar 17, 2019

This is related to #5704 -- but I suspect even more common a problem. I discovered this while testing the new --path-warnings (coming in Hugo 0.55) on some sites.

This is from Let's encrypt's website, a French translation of one of the pages:

---
title: Chaîne de confiance
slug: certificates
top_graphic: 5
aliases: [/certs]
---

It's easy to see what has happened here: They have copied the English original and translated the language strings.

The problem is, however, that /certs will point to the server root, so it will be a little random which language will get the redirect.

We cannot change the meaning of /certs in the example above, but I suggest we do as in #5704 and say that alias definitions not starting with a leading / is considered relative to the language root where they belong, e.g.:

---
title: Chaîne de confiance
slug: certificates
top_graphic: 5
aliases: [certs]
---

/cc @regisphilibert @kaushalmodi @budparr

@bep bep added this to the v0.55 milestone Mar 17, 2019
@bep bep self-assigned this Mar 17, 2019
@kaushalmodi
Copy link
Contributor

say that alias definitions not starting with a leading / is considered relative to the language root where they belong

I have a feeling that that won't be very intuitive.

Seeing aliases: [certs], I think that that's the page aliases respective to its current path.

Is there a possibility to use special variables like $langroot? Example: aliases: [$langroot/certs]

@bep
Copy link
Member Author

bep commented Mar 17, 2019

Is there a possibility to use special variables like $langroot? Example: aliases: [$langroot/certs]

How is that more intuitive? And would a page alias in the same folder be a common enough use case to even be considered? I did not make that connection with the above. Also, keep in mind that a solution to this would have to be simple (also to implement) to get in the next release -- I need to either fix this or remove/hide the new duplicate path warning thing.

@kaushalmodi
Copy link
Contributor

kaushalmodi commented Mar 17, 2019

would a page alias in the same folder be a common enough use case to even be considered?

I can't speak for everyone. But I have uses page aliases many times. It's usually when I have published a post, and then later rename it to something better.

A very common general purpose application is to have shorturl aliases for each post (which I auto generate and insert to front-matter).

One can argue that you can use the redirects too. But having aliases for a page in that page's front matter is useful too.

Just my few cents.

@bep
Copy link
Member Author

bep commented Mar 17, 2019

I can speak for everyone. But I have uses page aliases many times. It's usually when I have published a post, and then later rename it to something better.

Yea, ok, that's fair. I have probably done the same. I will ... think about it.

@bep bep changed the title Allow relative alias in front matter Allow relative page-relative alias in front matter Mar 17, 2019
@bep bep changed the title Allow relative page-relative alias in front matter Allow page-relative alias in front matter Mar 17, 2019
@bep
Copy link
Member Author

bep commented Mar 17, 2019

@kaushalmodi I have thought about this, and I think you are right. Pate-relative aliases would solve the above problem and also be more flexible. Some alias variants would be:

  • /myalias; relative to the host root
  • ./myalias and myalias: Relative to the original page output file. So, if you change your permalink settings, the aliases will also move.
  • ../../myalias; same as above, but we will of course not navigate beyond the context root (i.e. the baseURL).

@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants