jekyll build produces a different result than jekyll server for a language switcher
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
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).
I know it's way belated, but @george-gca identified that not setting the jekyll configuration url causes different builds with jekyll serve (which automatically sets this to localhost) and jekyll build . A functioning site language switcher requires this to be set, or else all links become implicitly relative.
The polyglot readme has been updated to reflect this. I hope this helps!