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

Custom permalinks per post with different languages and jekyll-redirect-from #224

Open
idachev-shipcars opened this issue Jan 5, 2025 · 1 comment

Comments

@idachev-shipcars
Copy link

Hello, I want to set a custom permalink for my posts here with examples:

My EN page:

---
page_id: hf-power-amplifier-1kw
lang: en
title: 'HF Power Amplifier 1kW'
date: '2014-07-06T14:06:49+00:00'
author: lz2gl
permalink: /hf-power-amplifier-1kw/
...

My BG page:

---
page_id: hf-power-amplifier-1kw
lang: bg
title: 'HF Усилвател 1kW'
date: '2014-07-06T14:06:49+00:00'
author: lz2gl
permalink: /hf-усилвател-1kw/
...

As you can see, these two posts are linked with the page_id.

And what I expect is to have an English link https://mysite/hf-power-amplifier-1kw/ and a Bulgarian link https://mysite/hf-усилвател-1kw/.

But the second link is redirected to https://mysite/hf-power-amplifier-1kw/ with the Polyglot logic for jekyll-redirect-from.

My correct Bulgarian page is generated at https://mysite/bg/hf-усилвател-1kw/, but I do not want this. I'm expecting that if I say custom permalink: /hf-усилвател-1kw/, it will be generated as https://mysite/hf-усилвател-1kw/.

Do you have any idea how to handle this?

I'm migrating from WordPress to Jekyll, and this is stopping me as I have a lot of established good SEO with Bulgarian URLs.

@untra
Copy link
Owner

untra commented Jan 7, 2025

hello @idachev-shipcars 👋

Unfortunately the design of polyglot is meant to coordinate the alternate language sites namespaced under that language path, so the permalink of a bulgarian page will start with /bg/ if it's not your default language. If bulgarian is not the default language for your site, then all bulgarian pages are prefixed with /bg/ going forward with polyglot.

However jekyll-redirect-from does support defining additional specific redirects from existing routes, so in your bulgarian page you should be able to specify:

---
page_id: hf-power-amplifier-1kw
lang: bg
title: 'HF Усилвател 1kW'
date: '2014-07-06T14:06:49+00:00'
author: lz2gl
permalink: /hf-усилвател-1kw/
redirect_from:
  - /hf-усилвател-1kw/
...

and your existing links to https://mysite/hf-усилвател-1kw/ should redirect appropriately. Make sure you have a redirect.html setup to support this.

That said, I can see an improvement to be made in polyglot that could better support top-level redirects for custom language permalinks with redirects.
For example, https://polyglot.untra.io/yi-tiao-chao-chang-de-yong-jiu-lian-jie/permalink/ redirects to the default language page https://polyglot.untra.io/a-really-long/permalink/, when ideally it should redirect to it's chinese language couterpart https://polyglot.untra.io/zh-CN/yi-tiao-chao-chang-de-yong-jiu-lian-jie/permalink/ implicitly.

I hope this suggestion helps. Thank you for the feedback!

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

No branches or pull requests

2 participants