kurtsson / jekyll-multiple-languages-plugin

I18n support for Jekyll and Octopress
MIT License
923 stars 201 forks source link

{{ site.baseurl }} points to current page instead of pointing to the root of the site #136

Open PL4typus opened 5 years ago

PL4typus commented 5 years ago

Hello,

Example is here with code here

As you can see, the link to the root of the site (Blue Project in English, left-most link in the banner) works well for all non-default languages. For example, in the English version: If you are on Friends page and click on Blue Project it will take you there

But if the website is in default language, then {{ site.baseurl }} points to the current page (here /friends/ or /about/ or / depending on current page). For example, in the Croatian version: If you are on Naši prijatelji page and click on Plavi Projekt it will take you to Naši prijatelji page. Same with O nama (about us)

Did anyone else encounter that ? Could you suggest a work around ?

PL4typus commented 5 years ago

My workaround for now is in to use the base url in plain text if the language is the default one.

shushugah commented 5 years ago

Hello @PL4typus,

I cloned your repo and checked out to lang_plugin branch. I removed your if conditional for Croatian, but could not reproduce the error. Granted I was running it locally, instead of production. What windows environments are you running on?

I also verified that all links were working with html-proofer gem.

require 'html-proofer'

task :test do
  sh "bundle exec jekyll build"
  options = { :assume_extension => true }
  HTMLProofer.check_directory("./_site", options).run
end
keunes commented 1 year ago

Hello, We're experiencing the same issue with the AntennaPod website (e.g. 'Home' in breadcrumb on https://antennapod.org/documentation/getting-started).

I have this issue also when bundling & serving the site locally. Happy to help debug if I'm guided how to :-) (cc @shushugah)

Our workaround is to use /{% if site.lang != 'en' %}{{ site.lang }}{% endif %} for the base URL, where 'en' is our default language.

shushugah commented 1 year ago

I don't have much time to look into this, but basically for another website, what we did was translate the page.namespace, which correctly links to '/' in the case of the default language. See https://github.com/techworkersco/twc-site/blob/master/_includes/header.html#L36