I read a lot about these subjects and I know that no solution is perfect to handle a multilanguage site. I'm using different folder to serve content for different languages, thus I have www.example.com/en
, www.example.com/es
, etc.
When a user visit the site for the first time at www.example.com
I choose the best matching language from Accept-Language
HTTP header and redirect it to the most appropriate page using en
version if no language match. For this reason there is no real page at www.example.com
and it always generates a redirect.
This is working very well for both users and search engines however there is a flaw in this approach, likes are spread across different languages, I want all of them for www.example.com
If I set og:url
to root page FB crawler complaints about redirect loop because it goes from www.example.com
then it's redirected to www.example.com/en
which has og:url
set to www.example.com
. I want to keep likes unified i.e. a like for www.example.com/es
and a like for www.example.com/en
should both count for main domain.
My current solution is to modify the redirect code in this way: when user agent is facebook never redirect when www.example.com
is requested. Use default locale or locale requested by FB with fb_locale
param.
I've also added locale open graph tags to tell FB about different locales for my page.
Finally I kept the canonical url tag with the locale portion because each language is serving its own content in this way search engines should be aware of that. This is (more or less) the head section of the home page
<meta content="website" property="og:type" />
<meta content="http://www.example.com/" property="og:url" />
<meta content="en_US" property="og:locale" />
<meta content="es_ES" property="og:locale:alternate" />
<meta content="fr_FR" property="og:locale:alternate" />
<link href="http://www.example.com/en" rel="canonical" />
In this way everything seems to work and like count are shared across all languages. I'm only getting a warning by facebook debugger
Mismatch og:url and canonical url: og:url tag in the header is not the same URL as rel='canonical' link in the html.
Is this setup correct? Will I have any issue with this markup?
Similar question but he wants likes per country.