getgrav / grav-plugin-langswitcher

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

Absolute url #28

Closed jimblue closed 7 years ago

jimblue commented 7 years ago

As the documentation says:

{% include 'partials/langswitcher.hreflang.html.twig' %}

Will generate something like:

<link rel="alternate" href="http://example.com/en" hreflang="en" />
<link rel="alternate" href="http://example.com/de" hreflang="de" />

But this only works if user is using Absolute URLs setting of Grav. Without this settings it generate something like this:

<link rel="alternate" href="/en" hreflang="en" />
<link rel="alternate" href="/de" hreflang="de/" />

And that's not good, as "rel=alternate" are suppose to always be absolute for SEO.

So how make this work for those how want to keep their URLs relatives? (which is way better 😄)

jimblue commented 7 years ago

Hi! Any news about this?

jimblue commented 7 years ago

Guys, any ideas how to fix this?

mahagr commented 7 years ago

To be honest, I would use <base href="http://example.com"> tag instead of adding absolute links to everywhere. In fact, I would even get rid of the Absolute URLs setting in Grav as it has a few issues.

See: https://www.w3schools.com/tags/tag_base.asp

rhukster commented 7 years ago

I'm a little confused on your output. When I enable multilang and langswitcher my output looks like this this:

<ul class="langswitcher">
  <li><a href="/grav-cetaq/de" class="external active">Deutsch</a></li>
  <li><a href="/grav-cetaq/en/" class="external">English</a></li>
  <li><a href="/grav-cetaq/fr/" class="external">Français</a></li>
</ul>

Granted this is a sub-folder but the links are relative and there's no rel tag at all.

jimblue commented 7 years ago

@rhukster, indeed it seem to works now, sorry to didn't notice myself, it was an old pb, it's probably gone with new update.

Now the only bugremaining the missing backslash for inactive language. But I've already open an other issue for that. #29

Thanks for you help