getgrav / grav-plugin-langswitcher

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

wrong hreflang genereated when run in subdirectory #62

Closed splitbrain closed 2 years ago

splitbrain commented 3 years ago

I'm running my grav site in a subdirectory site. I have configured en and de as languages.

When I am on http://localhost/site/de/page, the following hreflang entries are generated (using the default partial that comes with the plugin):

<link rel="alternate" hreflang="de" href="http://localhost/site/de/page">
<link rel="alternate" hreflang="en" href="http://localhost/en/page">

Clearly the non-active language is generated wrong. Might be related to #43?

maofree commented 2 years ago

Hi I've found the same error to fix this issue it is necessary to add "base_url_simple" into langswitcher.hreflang.html.twig {% set lang_url = base_url_simple ~ (langobj.getLanguageURLPrefix(key) ~ langswitcher.page_route ~ page.urlExtension ?: '')|rtrim('/') %}

rhukster commented 2 years ago

This should be fixed in latest developer branch.