This repository has been archived by the owner on Jan 15, 2024. It is now read-only.
Add LocalizeLinks and custom permalinks for each lang #53
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi folks,
Currently, the plugin returns
/my_page
and/lang/my_page
but I needed to produce different urls depending on the language, like/team
and/fr/equipe
. I added the functionality to do so by adding a variable in the front matter like this :When french (fr) pages (or any languages) will be generated, the site will look for
permalink_fr
and use it if it exists, otherwise it will fallback to the defaultpermalink
. In this case, it would generate/team/index.html
and/fr/equipe/index.html
.I also created a new function
translate_links
, returning the correct link for a specified lang or, if not specified, for the current lang.To use that, pages need to have a unique namespace variable. This might not be the best solution, but as my first time with Ruby and Jekyll, this is what I came up with.
You can also create an easy lang switcher like so :
Waiting for your comments so we can make this live, as this would definitely be a nice feature to have.