You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My template includes the following to generate links to alternate languages:
{%- if get_alts(this) %}
<linkrel="alternate" hreflang="x-default" href="{{ this._path|url(alt="_primary",external=True)}}">
{%- for hreflang in get_alts(this) %}
<linkrel="alternate" hreflang="{{hreflang}}" href="{{ this._path|url(alt=hreflang,external=True) }}">
{%- endfor %}
{%- endif %}
However, the x-default link does not have a trailing slash, the ones generated via get_alts do.
I have a similar problem with missing trailing slashes in my sitemap:
<url><loc>{{ page._path|url(alt="_primary",external=True) }}</loc>
{%- for hreflang in get_alts(page) %}
{%- set apage = site.get(page._path, alt=hreflang) %}
{%- if apage.is_visible %}
<xhtml:linkrel="alternate" hreflang="{{ hreflang }}" href="{{ page._path|url(alt=hreflang,external=True) }}"/>
{%- endif %}
{%- endfor %}
</url>
again, the URL in loc is missing the trailing slash.
Note: I use content negotiation for handling the x-default URL, so it is different from my regular alt urls - all my alternatives have a URL prefix, and I never use the "non-overlay" version. I am not totally happy with the way alternatives are currently handled in lektor, which is designed around the idea that you have one primary language and second-class alternates, and does not allow for some pages to have one, and others the other language only (and still have a canonical URL). But independent of this, the output of above example is inconsistent by sometimes having the trailing slash, sometimes not.
My workaround now is to |trim("/") and always append a slash (as all pages will be saved as /index.html by lektor anyway).
The text was updated successfully, but these errors were encountered:
kno10
changed the title
No trailing slash on alt="_default"?
No trailing slash on alt="_primary"?
Dec 21, 2023
My template includes the following to generate links to alternate languages:
However, the
x-default
link does not have a trailing slash, the ones generated viaget_alts
do.I have a similar problem with missing trailing slashes in my sitemap:
again, the URL in
loc
is missing the trailing slash.Note: I use content negotiation for handling the
x-default
URL, so it is different from my regular alt urls - all my alternatives have a URL prefix, and I never use the "non-overlay" version. I am not totally happy with the way alternatives are currently handled in lektor, which is designed around the idea that you have one primary language and second-class alternates, and does not allow for some pages to have one, and others the other language only (and still have a canonical URL). But independent of this, the output of above example is inconsistent by sometimes having the trailing slash, sometimes not.My workaround now is to
|trim("/")
and always append a slash (as all pages will be saved as/index.html
by lektor anyway).The text was updated successfully, but these errors were encountered: