getgrav / grav-plugin-langswitcher

Grav LangSwitcher Plugin
https://getgrav.org
MIT License
28 stars 26 forks source link

Tailing slashes vary #52

Closed johBerlin closed 4 years ago

johBerlin commented 4 years ago

I have the problem, that tailing slashes are in hreflang tags are different for some languages. I changes the hreflang-twig so it would trim the tailing slash for the url:

<link rel="alternate" hreflang="{{ key }}" href="{{ rtrim(lang_url,"/") ~ uri.params }}" />

Now it works.

rhukster commented 4 years ago

Instead of that can you try simply wrapping the url in the url function? {{ url(lang_url) }}

johBerlin commented 4 years ago

nope. doesn't work with url() function. What would be the benefit?

johBerlin commented 4 years ago

I can also say about the bug: I run a bilingual page ... it adds a tailing slash to the other language in the hrefang tag. Not the one of the current page. Thus, I believe the tailing slash is related to the construction of the alternative hreflang tag:

{% set lang_url = base_url_simple ~ langobj.getLanguageURLPrefix(key) ~ langswitcher.page_route ~ page.urlExtension ?: '/' %}

Am I understanding this right: It adds a tailing slash if page.urlExtension is false?

If that is the case, why don't we make it a parameter in the plugin settings. Like "use tailing slashes true/false". Then everybody can decide on how to run urls.

johBerlin commented 4 years ago

I'll close this one then.