How to set the correct og:locale for this page's language and region?
og-locale-missing-or-incorrect page
The issue
A page without og:locale is declared as US English to every platform that reads its tags, whatever language it is written in. A page with the wrong value makes the same mistake on purpose. For a site in more than one language, the shares of every page outside US English describe themselves incorrectly.
The cause is that og:locale defaults to en_US in the Open Graph protocol, so leaving it out is a statement, not a blank. Templates often hard-code one value for every language the site publishes in.
Scope
Each page declares its own og:locale, which should follow the language of that page. On a multilingual site, the template has to set it per language, not once.
How to check you have it
- By hand: view the page source and find
og:localein the<head>. Compare it with thelangattribute on<html>:lang="en-GB"should pair withog:localeset toen_GB. - With a tool: Facebook’s Sharing Debugger lists the
og:localeit read.
Probeo doesn’t check og:locale.
The fix
Set og:locale to the page’s language and region in language_TERRITORY form.
The language is a two-letter ISO 639-1 code and the territory a two-letter ISO 3166-1 code, joined by an underscore: en_GB, es_MX, de_DE. Take it from the same source as the page’s lang attribute, so the two can’t disagree. If the page is also published in other languages, list each one with og:locale:alternate.
Done when: every page declares the locale of its own language, and the check above comes back clean.
Do not
- Do not copy the
langattribute’s hyphenated form, such asen-GB, intoog:locale. - Do not hard-code one locale for a site published in several languages.
- Do not declare a locale that doesn’t match the page’s main language.
FAQ
What is the difference between og:locale and the HTML lang attribute?
The lang attribute uses a hyphen, as in en-US, and is read by browsers and assistive technology. og:locale uses an underscore, as in en_US, and is read by platforms that build share cards. Both should name the same language.
Should og:locale always include a territory code, or can it be just the language?
Use the language_TERRITORY form the protocol defines. If the language has no meaningful regional variant for the page, use its most common territory, such as es_ES.
What happens if the page content mixes multiple languages?
Declare the main language in og:locale. Use og:locale:alternate for the other languages the page is available in, one tag each.
Can og:locale be omitted if the page is in English?
For US English, leaving it out gives the right answer, because en_US is the protocol’s default. For any other variant of English, declare it.
How do social platforms use og:locale when displaying shared content?
Platforms don’t document it in detail. What is certain is that the tag is the page’s own statement of its language, and a missing one is read as en_US.
Does og:locale affect search engine indexing?
No. Google determines a page’s language from its visible content and reads hreflang annotations for regional versions. og:locale is for share previews.
Which product detects this
Probeo checks this on every page of your site as part of Site Clarity. This page explains one instance; the product tells you every page that has it.