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 · 5 comments

Comments

Projects
None yet
2 participants
@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 the Enhancement label Mar 17, 2019

@bep bep added this to the v0.55 milestone Mar 17, 2019

@bep bep self-assigned this Mar 17, 2019

@kaushalmodi

This comment has been minimized.

Copy link
Member

kaushalmodi commented Mar 17, 2019

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

This comment has been minimized.

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

This comment has been minimized.

Copy link
Member

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

This comment has been minimized.

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

This comment has been minimized.

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).

bep added a commit to bep/hugo that referenced this issue Mar 30, 2019

bep added a commit to bep/hugo that referenced this issue Mar 30, 2019

bep added a commit to bep/hugo that referenced this issue Mar 30, 2019

bep added a commit to bep/hugo that referenced this issue Mar 31, 2019

@bep bep closed this in #5802 Apr 2, 2019

bep added a commit that referenced this issue Apr 2, 2019

nguyenvanduocit added a commit to 12bitvn/hugo that referenced this issue Apr 5, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.