Closed Toasterson closed 8 months ago
The path
arg in get_url refers to the markdown file, not the URL path. I'm not sure why it doesn't error but to get it to work like you need you can do:
diff --git a/templates/base.html b/templates/base.html
index 0ebdd1e..eef63e1 100644
--- a/templates/base.html
+++ b/templates/base.html
@@ -17,8 +17,14 @@
</div>
<div class="header">
<div class="language">
- <a href="{{ get_url(path=current_path, lang="de") }}">Deutsch</a>
- <a href="{{ get_url(path=current_path, lang="en") }}">English</a>
+ {% if section %}
+ <a href="{{ get_url(path="/", lang="de") }}">Deutsch</a>
+ <a href="{{ get_url(path="/", lang="en") }}">English</a>
+ {% else %}
+ {% for translation in page.translations %}
+ <a href="{{translation.permalink}}">{% if translation.lang == "de" %}Deutsch{% else %}English{% endif %}</a>
+ {% endfor %}
+ {% endif %}
</div>
<div class="nav">
<a href="{{ get_url(path="/", lang=lang) }}">{{trans(key="home", lang=lang) }}</a>
Oh, yeah that makes sense. Now it works thanks.
Bug Report
Environment
Zola version: 0.17.2
Expected Behavior
When using
The German Language link always points to the correct german link.
Current Behavior
In my current setup at https://gitlab.com/Toasterson/atelierwegi I have set the
default Language = "de"
and I am trying to get the Url of the current path for a simple language switcher. When I am in the default language every link is as expected. Once I Switch to english however the german language link is also a link to the english language. So whenlang="en"
in the template the language does not get correctly changed in get_url.Step to reproduce
See https://gitlab.com/Toasterson/atelierwegi but basically.
default_language="de"
<a href="{{ get_url(path=current_path, lang="de") }}">Deutsch</a>
to create a language link to the German version of the page.See https://atelierwegi-toasterson-620f5f93159cd6c95174bf09bc660c027f857d5e.gitlab.io/en/ Where the Link "Deutsch" in the upper left hand corner should be pointing to "/" but is pointing to "/en"