Skip to content

Ability to get a page URL in another language when page_id is used #199

Description

@hacketiwack

Context
I want to be able to have different URLs for posts in different languages. e.g:

  • /en/my-post/
  • /fr/mon-article/
  • /de/mein-blogartikel/

Today, this is possible to do it thanks to the page_id in the front matter of the post.
However, for this to work, you'll need to specify a permalink for each post, which is quite annoying.
Why? Because, if you can easily forget to enter this attribute and then switching from one language to another won't work.
In Jekyll, you can add a default permalink attribute for all the pages. However, this doesn't seem to be taken into account by polyglot. Thus accessing the permalink through permalink_lang[lang] doesn't work.

Experiments
What I tried so far, was to create a language selector that would retrieve all the site.posts and site.pages.
Why? Because, I wanted to access the url attribute of a post/page in another language.
However, these are already filtered out by polyglot before I access them.
Thus it's impossible to get this url attribute.
This is confirmed by these issues: 186, 53, 88.

Ideas
Reading issue 186, it seems there is no will to implement it.
However, is there any other way to get these URLs?
Would it be possible to implement an attribute url_lang similar to the permalink_lang?

Thanks for any advice.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions