Hello,
I made a multilingual website with Babel (2 contexts) and would like to make correct usage of the hreflang attribute, i.e. for example for a fictional website www.examplesite.de/ex1de.html there would be hreflang-attributes as follows:
<link rel="alternate" hreflang="de" href="
http://www.examplesite.de/ex1de.html/" />
<link rel="alternate" hreflang="x-default" href="
http://www.examplesite.de/ex1en.html/" />
x-default would be English in this case, if the language should not be “de”.
After browsing for a while, I found the following solution:
1) In the template of the page: BabelLinks call
[[BabelLinks? &tpl=`hreflangTemplateChunk`]]
2) The according hreflangTemplateChunk:
<link rel="alternate" hreflang="[[+cultureKey]]" href="[[+url]]" />
Unfortunately, this does only work partially, because the produced entry in the <head> of the page does only relate to the other language. But there is no self-referencing of the active language version.
Moreover, being on the DE page, the hreflang attribute is only shown as „en“, then. How is possible, to use “x-default” instead of “en”, as shown in the examples above.
I am not that much into MODX programming, unfortunately.
Thanks a lot!
[ed. note: mic0001 last edited this post 11 years, 2 months ago.]