/ โ† Open Graph Fixes / og:locale
In this guide
  1. The format og:locale expects
  2. How much it matters, honestly
  3. Where a wrong value comes from
  4. Generating the right value in code
  5. The fix, step by step
  6. When og:locale:alternate belongs in the block
  7. Edge cases
  8. Keeping the locale right
  9. Questions and answers

The format og:locale expects

The Open Graph protocol defines og:locale as the locale the tags are marked up in, written as language_TERRITORY. If the tag is absent, the protocol says readers should assume en_US. That default is the reason the tag matters to a British site at all: without it, you are formally declaring American English.

Value foundProblemCorrect value
en-GBHyphen instead of underscore; this is the lang attribute formaten_GB
en_UKUK is not the ISO country code for the United Kingdomen_GB
EN_gbCase reverseden_GB
enNo territoryen_GB, or whichever country the content is written for
en_US on a British siteValid, but describes the wrong variety of Englishen_GB
english or British EnglishA name, not a codeen_GB
cy_WA for WelshWA is not a country code; Wales falls under GBcy_GB

The United Kingdom's ISO code is GB. UK is reserved in the standard but is not the code assigned to the country, so a strict reader treats en_UK as unknown. The same code is used for every nation within the UK: English in Scotland is en_GB, Welsh is cy_GB, Scottish Gaelic is gd_GB. For the Republic of Ireland, English is en_IE and Irish is ga_IE.

How much it matters, honestly

A wrong og:locale will not usually break a link card. The title, description and image appear whatever the locale says. So it is fair to ask why a validator flags it.

What og:locale does not do is tell Google which country to show a page in. Google uses hreflang annotations and other signals for that. Treat og:locale as accurate labelling for sharing platforms, not as a search targeting tool.

๐Ÿ’ก If the generator flags the locale alongside missing core tags, fix the core tags first; fixing missing core OG tags covers them. The locale is a refinement.

Where a wrong value comes from

Very few people type an og:locale value by hand. It is usually derived from a language setting somewhere else, and the error is in that setting or in the conversion.

A CMS language left on the default

WordPress installs in American English unless you choose otherwise, and SEO plugins such as Yoast and Rank Math build og:locale from the site language. If Settings โ†’ General โ†’ Site Language says English (United States), the tag says en_US. Switching it to English (UK) changes the tag to en_GB, and also changes the language of the admin screens and some theme text.

A hyphenated code passed straight through

Many systems store locales as en-GB, the BCP 47 form used by the lang attribute and hreflang. A template that prints that value straight into og:locale gives the hyphen form. The fix is a conversion, covered below, not a different setting.

A language with no country

Shopify, many headless CMSs and some translation plugins store just the language, en or fr, for each version of a site. Printing that alone gives a code with no territory. Combine it with the market's country code, or map it to a full code.

A hard-coded value in a shared layout

On multilingual sites, og:locale is sometimes written once in the base layout. Every language then declares the same locale. The value has to come from the language of the page being rendered.

Generating the right value in code

Keep one source of truth for a page's language, usually the BCP 47 form such as en-GB, because that is what lang and hreflang need. Derive the Open Graph form from it with a small conversion that also rejects the UK mistake.

function toOgLocale(tag, fallbackCountry = 'GB') {
  const [lang, region] = String(tag).replace('_', '-').split('-');
  let country = (region || fallbackCountry).toUpperCase();
  if (country === 'UK') country = 'GB';
  return `${lang.toLowerCase()}_${country}`;
}

toOgLocale('en-GB');   // en_GB
toOgLocale('en_uk');   // en_GB
toOgLocale('cy');      // cy_GB
toOgLocale('fr', 'FR'); // fr_FR

The same idea works in any template language. In PHP, str_replace('-', '_', $tag) followed by fixing the case does most of the work. The important part is that the fallback country is a decision you make for your site, not the protocol's US default.

Next.js

The Metadata API has dedicated fields. Set openGraph.locale in the root layout and override it in any route that serves another language.

export const metadata = {
  openGraph: {
    locale: 'en_GB',
    siteName: 'Harlow Street Bakery',
  },
};

Shopify

If your theme prints og:locale, build it from the storefront's language and market country rather than typing a value. The Liquid objects request.locale.iso_code and localization.country.iso_code give you the two parts; take only the language part of the first, join them with an underscore, and print the result.

{%- assign og_lang = request.locale.iso_code | split: '-' | first -%}
<meta property="og:locale" content="{{ og_lang }}_{{ localization.country.iso_code }}">

Check the output on each market you run, because a store selling to several countries in one language will then declare a different territory for each market, which is accurate.

The fix, step by step

Step 1

Read the current locale values

Run a page through the OG / Twitter Tag Generator and note what it reports for the locale, then open view-source and search for og:locale. Record the primary value, every og:locale:alternate value, and the lang attribute on the html element. On a multilingual site, repeat this for one page in each language, because a hard-coded value only shows up when you compare languages side by side.

Step 2

Work out the correct code

Decide the language the page is actually written in and the country whose conventions it follows. A UK business writing British English needs en_GB; Welsh pages need cy_GB; an Irish site in English needs en_IE. Use the underscore, a lower-case language and an upper-case country, and use GB rather than UK. Write the answer for each language version down before touching any settings.

Step 3

Fix the source of the value

Find what feeds the tag instead of editing the tag. In WordPress, set the site language under Settings, General, to English (UK) so Yoast or Rank Math print en_GB. In other systems, correct the language or market setting, or the translation plugin's configuration for each language. Only hard-code a value in a single-language site's template if nothing else sets it, and never in a layout that serves several languages.

Step 4

Convert the format in one place

If the stored value is in the hyphen form used by the lang attribute, add one conversion function that swaps the hyphen for an underscore, fixes the case, replaces UK with GB and adds your chosen country when only a language is stored. Use that function wherever og:locale or og:locale:alternate is printed, so no template does its own conversion and gets it slightly different.

Step 5

Add alternates only where they apply

List og:locale:alternate values only when the same address can serve the content in another language. If each language lives at its own address, give each page its own primary og:locale and connect the versions with hreflang instead. Remove any alternates for languages the site does not actually offer, and never repeat the primary locale as an alternate of itself on the same page.

Step 6

Check it agrees with the lang attribute

Purge the page cache and reload the source. The lang attribute and og:locale should describe the same language and country in their own formats, such as en-GB and en_GB. Run the page through the generator again to confirm the locale is accepted, then check one page in each other language to confirm each carries its own locale rather than the default.

When og:locale:alternate belongs in the block

The protocol describes og:locale:alternate as an array of other locales the page is available in. Read literally, that means the same address, not a translation somewhere else. It suits a small number of set-ups.

Set-upog:localeog:locale:alternate
English-only siteen_GBNone
English and Welsh at separate addresses (/cy/โ€ฆ)Each page declares its own: en_GB or cy_GBNone; use hreflang to link the pair
One address that switches language by a cookie or headerThe default language servedEach other language that address can serve
A bilingual page with both languages side by sideThe main languageThe second language
<meta property="og:locale" content="en_GB">
<meta property="og:locale:alternate" content="cy_GB">

Each alternate gets its own tag; do not put a comma-separated list in one content attribute. Order does not carry meaning, but keep the primary og:locale first so the block is easy to read.

โš ๏ธ Serving different languages at one address by reading a cookie or the browser's language header makes life hard for every crawler, not just sharing bots, because they usually arrive with no cookie and a single language. Separate addresses per language are more robust. Facebook has in the past offered a way for its crawler to request alternate locales from one address, but it is not something to build a new site around.

Edge cases

For the relationship between language versions in search, see fixing hreflang and canonical conflicts. Each language page's og:url should name that language's own address, as explained in fixing og:url and canonical mismatches.

Keeping the locale right

Questions and answers

1. What is the correct og:locale for a UK website?

For content written in British English it is en_GB, with a lower-case language code, an underscore and the upper-case country code. The country code for the United Kingdom is GB, not UK, so en_UK is invalid even though it looks natural. The same GB code covers England, Scotland, Wales and Northern Ireland; Welsh-language pages would use cy_GB and Scottish Gaelic pages gd_GB. If the tag is absent altogether, readers are told to assume en_US.

2. Why does my site say en_US when I am in the UK?

Usually because a language setting was left at its default. WordPress installs in English (United States) unless you choose otherwise, and SEO plugins such as Yoast and Rank Math build og:locale from that site language. Changing Settings, General, Site Language to English (UK) changes the tag to en_GB. Other platforms have a similar store or site language setting. Fixing the setting rather than the tag keeps everything that depends on it consistent.

3. Is og:locale the same as the html lang attribute?

They describe the same thing in different formats. The lang attribute uses the BCP 47 style with a hyphen, as in en-GB, and browsers and screen readers read it. The og:locale tag uses an underscore, as in en_GB, and sharing platforms read it. Both should describe the same language and country for a given page. The simplest approach is to store the language once and convert it into each format when the page is printed.

4. Does og:locale help my site rank in the UK?

No. Google does not use og:locale to decide which country to show a page in. Country and language targeting in search relies on hreflang annotations, the language of the content itself, the domain and other signals. og:locale is labelling for sharing platforms and other readers of Open Graph data. It is worth getting right because it is cheap and accurate labelling helps those systems, but it is not a lever for search visibility in any particular country.

5. Should I list every language my site offers in og:locale:alternate?

Only if the same address can serve all of them. The protocol describes alternates as other locales this page is available in. If each language has its own address, such as a Welsh page under a cy folder, each page should declare its own primary locale and the versions should be connected with hreflang. Listing languages that a page cannot actually show gives readers a false description and adds noise without any benefit.

6. Does a wrong og:locale stop my preview from showing?

Almost never. The major platforms display the title, description and image regardless of the declared locale, so a card with en_US on a British page looks exactly the same. That is why the locale is a lower-priority finding than a missing image or a wrong og:url. It is still worth fixing, because it is often a sign that a language setting is wrong, and that setting can also affect date formats, spelling and accessibility.

7. What locale should a bilingual English and Welsh page use?

If one page shows both languages together, declare the main language as og:locale, for example en_GB, and the second language as og:locale:alternate, cy_GB. If the site has separate English and Welsh pages, which is more common and easier for every kind of crawler, each page declares only its own language: en_GB on the English page and cy_GB on the Welsh one, with hreflang linking the two versions for search engines.

Check your locale and the whole OG block

The OG / Twitter Tag Generator builds the Open Graph and X card block for your page, validates it against the requirements of Facebook, LinkedIn and X, predicts how the preview will render and flags every tag that is missing or invalid.

Open Open Graph Fixes โ†’
๐Ÿ’ฌ Got a problem?
Related Guides: All Open Graph Fixes  ·  Fixing Missing Core OG Tags  ·  Fixing og:url and Canonical Mismatches  ·  Open Graph Guide  ·  Learning Hub

About aiwebpageseo

aiwebpageseo.com is a data-driven SEO and AEO (Answer Engine Optimisation) platform providing a free suite of technical SEO tools. Rather than relying on AI-theorised assumptions, the platform analyses live URL performance, delivering objective diagnostics, page speed metrics, CLS debugging, and site crawl data alongside actionable technical tutorials.