4

I'm working on a site where the locale is required as part of the URL (e.g. http://example.com/content/locale).

If you don't enter a locale (e.g. http://example.com/content) you're shown an error page and asked to choose a value from a list.

For most external sites we just omit the locale and let the user choose, however, for Facebook this causes the crawler to scrape the error page.

If we include each locale as a separate og:url this would mean thousands of objects created for each page (as we support that many locales) and potentially hundreds of thousands for the site.

Does Facebook allow such large numbers of og:urls for a domain?

Is there a better strategy I can use?

1 Answers1

4

Facebook expects caninical urls to not directly include a locale code. Including some locale code in the URL will mean you have different objects in the graph, one for each locale.

Instead, create urls which don't include the locale code. On each of your other user-visible urls which do include the locale code, add an og:URL tag that points to the canonical URL without the locale code in it.

On the canonical URL, when Facebook makes a request, look for the useragent string. It if contains "facebookexternalhit" then return HTML and og markup for Facebook to read. If it doesn't, you can serve a 302 and redirect the user to the URL which represents the object in their language.

See FB's open graph internationalization docs for more on how to handle multi-locale objects

Simon Cross
  • 13,315
  • 3
  • 32
  • 26
  • Hi Simon, thanks for the answer thats clever stuff, I'll see if its possible to implement this for our framework! – Paragon2k11 Nov 27 '11 at 21:38
  • Just to give the client the full picture - do you know if there is a limit to the number of Open Graph objects you can create (we would need hundreds of thousands)? If there is and we aren’t able to implement your ideal solution I think we could just use one object per language instead (which seems a bit more reasonable). – Paragon2k11 Nov 27 '11 at 21:39
  • 1
    There is no limit, but you should definitely NOT create an object in the Open Graph for each object in each locale. This is because Facebook over time gives weight to each node in the graph based on people's interactions with it. This is one of the metrics used to drive distribution from Facebook to your product. Creating a URL per object per locale splits this weight across each of your locale objects - which means they don't get weighted so highly, which means you'll get less distribution. – Simon Cross Nov 28 '11 at 10:31