Closed Karmalakas closed 3 years ago
Not sure it's working as expected. This is what I get: https://i.imgur.com/QfEudUe.png if I visit the Spanish page, https://qabiria.com/es. Code in base.html.twig is:
{% include 'partials/langswitcher.hreflang.html.twig' %} <link rel="canonical" href="{{ page.canonical(true) }}{{ uri.params('page') }}" />
Not sure it's working as expected. This is what I get: https://i.imgur.com/QfEudUe.png if I visit the Spanish page, https://qabiria.com/es. Code in base.html.twig is:
{% include 'partials/langswitcher.hreflang.html.twig' %} <link rel="canonical" href="{{ page.canonical(true) }}{{ uri.params('page') }}" />
Looks fine. What do you expect? :) Maybe x-default
could also be added there, but I believe that's another issue. I don't fully understand when it should be present actually.
If you look at the image, you'll see that the base URL is considered with the language code, such as https://qabiria.com/es so that all alternate are built upon it and resulting in wrong URLs, such as https://qabiria.com/es/es, https://qabiria.com/es/en and https://qabiria.com/es/it, instead of https://qabiria.com/es, https://qabiria.com/en, https://qabiria.com/it. Again, I don't know why this happens and if it's my configuration or not. However, the line of code that generates those metadata are only controlled by langswitcher, so my bet is that the error depends on it.
Ah.. I see what you mean. Same on my page when url already has lang part in it.. Can check this in ~8 hours - I'm at work now :( Already had similar issue with images when Grav is installed not on root :/
If someone could check this sooner, please do. If not, I'll let you know when I have a PR
@marcocevoli, I really tried to test every URL format I could think of. You can take the template and help check if it works as expected now. Here's the PR
i've merged this into the develop branch, so should be easier to test there
@ptarmic please create a new issue on this, otherwise, your comment may be lost.
Hi there are other problems with hreflang, x-default and urls on the language selector https://github.com/getgrav/grav-plugin-langswitcher/issues/63
Google complains about hreflang URL being invalid. When full URL provided, complaints are gone