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

jekyll build produces a different result than jekyll server for a language switcher #206

Open
thebravoman opened this issue Jun 3, 2024 · 1 comment

Comments

@thebravoman
Copy link

thebravoman commented Jun 3, 2024

This is the language switcher

       {% for tongue in site.languages %}
          <a {% if tongue == site.active_lang %}style="font-weight: bold;"{% endif %} {% static_href %}href="{% if tongue == site.default_lang %}{{page.url}}{% else %}{{site.baseurl}}/{{ tongue }}{{page.url}}{% endif %}"{% endstatic_href %} >{{ tongue }}
          </a>
          {%- if forloop.last == false -%}
            {{"/"}}{{ site.langsep }}
          {%- endif -%}
        {% endfor %}

This is the config

title: My
email: [email protected]
description: >- # this means to ignore newlines until "baseurl:"
  Write an awesome description for your new site here. You can edit this
  line in _config.yml. It will appear in your document head meta (for
  Google search results) and in your feed.xml site description.
baseurl: "" # the subpath of your site, e.g. /blog
url: "" # the base hostname & protocol for your site, e.g. http://example.com

# Build settings
plugins:
  - jekyll-feed
  - jekyll-polyglot

languages: ["en", "bg"]
default_lang: "en"
exclude_from_localization: ["assets"]
parallel_localization: true

Running jekyll serve produces _site/bg/index.html

    <a  href="/" >en
          </a>/
          <a style="font-weight: bold;" href="/bg/" >bg
          </a>

Running jekyll build produces _site/bg/index.html

    <a  href="/bg/" >en
          </a>/
          <a style="font-weight: bold;" href="/bg/" >bg
          </a>

Is this the expected behaviour or am I missing something? You see how the href in the first case is / and in the second it is bg

@gilgongo
Copy link

gilgongo commented Sep 10, 2024

From what I can tell, there is something in jekyll build/ployglot that sees href= and prepends the language directory to {{page.url}} no matter what. Remove the href= and it gives the correct path (which obviously breaks the HTML).

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