How to set og: url when a locale is required?

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

If you did not specify the locale (for example, http://example.com/content ), you will be shown a page with an error and will be asked to select a value from the list.

For most external sites, we simply omit the locale and allow the user to choose, but for Facebook, this forces the scanner to clear the page with an error.

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

Does Facebook allow so many og: urls for a domain?

Is there a better strategy I can use?

+4
source share
1 answer

Facebook expects caninical urls will not directly include locale code. Including the locale code in the URL means that there are different objects on the graph, one for each locale.

Instead, create URLs that do not include the locale code. At each of your other user-visible URLs that include the locale code, add an og: URL tag that points to the canonical URL without the locale code.

In the canonical URL, when Facebook makes a request, find the line useragent. It, if it contains "facebookexternalhit", then returns the HTML and og markup for reading Facebook. If this is not the case, you can file 302 and redirect the user to the URL that represents the object in your language.

For more information on internationalizing FB diagrams, see multilingual object processing documents.

+4
source

Source: https://habr.com/ru/post/1383102/


All Articles