We have multiple basestores with multiple languages and want to implement the hreflang tags to all pages (if easier, it might not include cart and checkout) telling the searchengines that there are multiple versions of the same page in different languages.
We followed the guide on Automatic Context Configuration to provide the multiple basestores.
We also added the SiteContextSelectorComponent to allow the user to change the language.
At the moment all pages face the same structure:
https://company.com/us/en/c/CategoryName -> where us is the country and en the language
Other examples:
https://company.com/us/es/c/CategoryName -> us store with spanish language
https://company.com/us/de/c/CategoryName -> us store with german language
https://company.com/de/de/c/CategoryName -> de german store with german language
The hreflang tags should be generated like
<link rel="alternate" hreflang="en-us" href="https://company.com/us/en/c/CategoryName" />
<link rel="alternate" hreflang="es-us" href="https://company.com/us/es/c/CategoryName" />
<link rel="alternate" hreflang="de-us" href="https://company.com/us/de/c/CategoryName" />
<link rel="alternate" hreflang="de-de" href="https://company.com/de/en/c/CategoryName" />
<link rel="alternate" hreflang="x-default" href="https://company.com/c/CategoryName" />
Working with meta resolvers might not work, due to the fact, that the tags are link and not meta.
So what's the spartcus way to do this?
A (angular) solution might be, injecting the document and adding the tags this way. But is this really the preferred way? And a further question would be, where's the right place to add these tags (on languageswitch? or routechange?)
Kind regards and thanks for your help, Andreas