I have three pages with the same content, in different languages.

When someone presses the share/like button on the dutch (nl) version I expect that the like is being shared with the english and german version. I have set the og:url to the english version (I guess I do have to pick a version). But the problem I now have is that the Facebook scraper looks at the english version for meta tags. So people see an English title/description when they share the dutch version.

According to the the Facebook documentation I can take a look at the X-Facebook-Locale header to serve the meta tags in the right language. But than I should serve an English page with Dutch meta tags to the Facebook crawler.

Not only is this taunting my OCD, but it also makes the code more complicated. Because the meta tags are set at different points in the request pipeline, I have multiple places where I have to switch between Cultures.

Another approach I was thinking about, is to see if there is an X-Facebook-Locale header and then do a redirect to the appropriate language, but for some strange reason that also doesn't seem to work.

What to do?

没有正确的解决方案

其他提示

If the Facebook crawler comes to you with a X-Facebook-Locale header, then you should indeed pass it the localized OG tags. But be sure to keep one common URL.

How we (will) solve this on our site:

  • http://example.com/elephant is a "neutral" URL, and redirects to the /en, /nl or /de version based on the user session, or browser language preferences.
  • All language-specific URLs have this neutral URL in their og:url. This is the object that gets saved in the graph.
  • If Facebook comes to us with a X-Facebook-Locale header, we serve the same content (whether it is at /en, /nl or /de), but with the relevant tags localized.
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top