Fix x-default so that it uses the default language instead of the currently active language.
syastrov
Branch: syastrov/django_hreflang:master
Branch: mverleg/django_hreflang:master
Merged
Merged pull request
Merged in syastrov/django_hreflang (pull request #3)
I have a project with default language set to German (LANGUAGE_CODE = 'de'). Am using the default Django LocaleMiddleware. In connection with that, I have a list of i18n_patterns in urls.py. In this example, I have used
i18n_patterns(..., prefix_default_language=False)
, which is why the German URLs should be "/" instead of "/de/".When visiting /en (e.g. a non-default language), I get this output, which is different from the output when visiting / (the same page in the default language):
<link rel="alternate" hreflang="x-default" href="/en/" /> <link rel="alternate" hreflang="de" href="/" /> <link rel="alternate" hreflang="en" href="/en/" />
x-default href should be "/" (The page in the default language).
After the fix, the result is:
<link rel="alternate" hreflang="x-default" href="/" /> <link rel="alternate" hreflang="de" href="/" /> <link rel="alternate" hreflang="en" href="/en/" />
Thanks for a nice project!