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

using only jekyll build seems to break the static_href tag #203

Open
lucmartinon opened this issue May 20, 2024 · 5 comments
Open

using only jekyll build seems to break the static_href tag #203

lucmartinon opened this issue May 20, 2024 · 5 comments

Comments

@lucmartinon
Copy link

Hello,

I commented on #158 2 weeks ago, but got no answer so opening a new one!

I would like to reopen this issue: I also have a project where I don't use jekyll serve, only jekyll build, since I have anyway an nginx server running to serve a data api. I seems to me that this is causing the static_href tag to not function.

I added a detailled example on a personal website that is in construction:

code here:
https://gitlab.com/lucmartinon/cnrs_pfas_web/-/blob/main/frontend/pages/about.fr.md?ref_type=heads

which is published here
http://vps-8ea64a15.vps.ovh.net/fr/about/

the link to /about is changed to /fr/about although it is in a static_href tag.

Beside this, fantastic plugin! thanks a lot!

@george-gca
Copy link
Contributor

It is weird because in my template site it is working. Even though I use jekyll serve to do local tests, when I upload to GitHub pages I use jekyll build, as can be seen in this workflow. I use the static_href tag to do the language switcher, which is done here and you can see it working on the demo page. One thing that I do before calling jekyll build is export JEKYLL_ENV=production. Maybe this changes something for your case? Idk.

@lucmartinon
Copy link
Author

I tried locally to set JEKYLL_ENV=production and it didn't solve the problem.

To be honest, I am not sure that the problem comes from jekyll serve vs jekyll build. This is what was suggested in #158, and since I am using jekyll serve I thought so, but I am not sure. It could also be that the problem comes from running Jekyll in a docker rather than directly on my machine, although I don't see why that should change anything.

Do you have any idea on how to investigate further? I'm happy to spend time on it, but I don't know where to start

@george-gca
Copy link
Contributor

If you run both jekyll serve and jekyll build inside a docker but only one of them works, then the problem is not with docker.

One test to be done: try to remove the if from inside the static_href, rather do it outside.

If this doesn't work I would suggest you changing how you create the localized pages and see if this changes anything. For example, in my template I have different directories for each language and use the page_id front matter variable to identify the same page from different languages.

@lucmartinon
Copy link
Author

I was not able to run jekyll serve, something was failing and I was not able to see the results, so I am not sure the problem comes from there.

I removed the if but still not working.

However I found a dirty workaround that I will use for now: since the problem is only with the links to the default language on the non-default-language page, I can add a fake language as a default language, skip this language in the loop to display my languages.

That means putting a redirect on in all my pages in case someone accesses the page without language, but that works, and that way I detect the browser language too, which is better than using the default language anyway.

@AndreasMadsen
Copy link

AndreasMadsen commented Sep 30, 2024

I have the same issue. Personally, I don't really need the auto-correcting links feature. I can just do it manually using something like {{ site.data[site.active_lang].strings.urlprefix }}. So I disabled the feature with this hack:

# file: _plugins/hack.rb
# prevent href correction, due to https://github.com/untra/polyglot/issues/203
def hook_process(site)
end

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

3 participants