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

Won't switch back to default language in Github Pages #194

Open
alejandrocs98 opened this issue Apr 2, 2024 · 3 comments
Open

Won't switch back to default language in Github Pages #194

alejandrocs98 opened this issue Apr 2, 2024 · 3 comments

Comments

@alejandrocs98
Copy link

Hi! Thanks for developing this plug-in, I think is awesome.
I am having a problem when deploying my website in Github Pages, it is working to switch from the default language to the other one, but switching back to the default language does not works. When I tested locally in my computer locally it works perfectly.
i will really appreciate if you could help me to solve this, I have not been able to spot the issue.
Here is how I have defined my language switcher in my header.html:

{% assign lang = site.active_lang %}
{% for l in site.languages %}
  <li><a {% if l == lang %}style="font-weight: bold;"{% endif %}
    {% static_href %}href="{% if l == site.default_lang %}{{site.baseurl}}{{page.url}}{% else %}{{site.baseurl}}/{{ l }}{{page.url}}{% endif %}"{% endstatic_href %}>{{ l }} {% if l == 'en' %} <span class="flag-icon flag-icon-gbr"></span> {% else %} <span class="flag-icon flag-icon-esp"></span> {% endif %} </a></li>
  {% if forloop.last == false %}<li role="separator" class="divider"></li>{% endif %}
{% endfor %}

And here is an example of the front matter for one of my pages:

---
title: "Team"
layout: gridlay
excerpt: "BCEM - Team"
sitemap: false
permalink: team/
lang: en
inheader_order: 1
---

Just in case here is my project in case it helps and you have time to check it: https://github.com/alejandrocs98/multilingual-research-group-website

Thanks!

@george-gca
Copy link
Contributor

Maybe the problem is the if/else inside the {% static_href %} tag. Try to invert this, like using the if/else outside. This is the only difference I can see from your code to mine. To check where I do this search for static_href inside this code. You can see it working in my demo site.

@alejandrocs98
Copy link
Author

Thanks for your suggestion! I already changed. It still does not work and I don't understand why but at least I believe that the code looks much better now. Also, you have a very cool website template!! I might switch to using yours instead!! :)

@george-gca
Copy link
Contributor

Feel free to use it, it was created for academics. It is actually a fork of al-folio with multilingual support, but I am also currently a maintainer there, so I try to contribute there and keep my template in sync with the latest al-folio changes.

Another difference I just found is in our config files, where I also use lang_from_path: true for polyglot, so I can keep my files for different languages in different directories. Maybe that helps.

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