Check 23.07 · Hreflang and regional variants

Use en-GB rather than en-UK

Replace en-UK with en-GB in your hreflang annotations, sitemaps and headers, on WordPress, Shopify, Drupal, Laravel or Next.js, and avoid reserved codes.

Priority
Critical
Difficulty
Easy
Estimated time
30 min to 2 h
Free, no account: your progress is saved in this browser.

Ask an AI to check this point on your site

Opens the assistant with a ready-made question: this check, its goal and your site URL.

For Gemini, Copilot or another assistant, copy the question. The link opens the chosen service directly: nothing goes through this site.

In short

The United Kingdom's country code in the ISO 3166-1 alpha-2 standard is GB, not UK. An hreflang="en-UK" annotation therefore does not target British searchers: Google ignores the region part of a reserved code. The task consists of finding every occurrence of en-UK (and of other reserved codes such as EU or UN) in the HTML, sitemaps, HTTP headers and CMS settings, then replacing them with en-GB. Once it is done, the British version of the site is announced with a code that search engines recognize.

Why it matters

An hreflang annotation consists of an ISO 639-1 language code (en) followed, optionally, by an ISO 3166-1 alpha-2 region code (GB). Google only supports codes assigned in these two standards.

UK, however, is not an assigned code: it is "exceptionally reserved" in ISO 3166-1 at the request of the United Kingdom, whose official code is GB (for Great Britain). It is a classic trap, because the British country domain is .uk and everyday usage says "UK". Google's documentation specifically cites EU, UN and UK among the reserved codes that have no effect in Search: Google ignores that part of the annotation.

In practice, a page annotated en-UK loses its British targeting. If the site also has an en-US version and an en-AU version, Google no longer has a version explicitly intended for the United Kingdom and may show the American page, with its prices in dollars, to a searcher in London. Audit tools also flag these codes as invalid, which muddles monitoring.

The same trap affects other codes: jp is not a language (Japanese is ja), se designates Northern Sami and not Swedish (sv), dk is not a language (Danish is da). These confusions are covered by validate ISO 639-1 language codes (opens in a new tab) and validate ISO 3166-1 Alpha-2 country codes (opens in a new tab).

What it improves

  • Targeting of the United Kingdom The British version becomes eligible again to replace the other English versions in results intended for the United Kingdom.
  • Click-through rate and conversion British visitors see prices in pounds and the delivery times and legal notices that apply to them.
  • Audit quality "invalid region code" alerts disappear from crawling tools.
  • Generative engines No documented effect. AI crawlers publish no rules on hreflang; a correct code only avoids sending contradictory signals.
  • Rankings No direct effect. hreflang does not push a page up; it helps serve the right version.

How to check

1. In a page's source code. Look for the codes in question, ignoring case (the hreflang value is not case-sensitive):

curl -s https://example.com/ | grep -o -i -E 'hreflang="[a-z]{2}-(uk|eu|un)"'

No result: compliant. A line with hreflang="en-UK" or hreflang="en-uk": to be fixed.

2. In the sitemaps, if the annotations are declared there:

curl -s https://example.com/sitemap.xml | grep -c -i -E 'hreflang="[a-z]{2}-(uk|eu|un)"'

For a sitemap index, repeat the test on each listed sitemap.

3. In the HTTP headers, for PDFs or files annotated with a Link header:

curl -s -I https://example.com/docs/guide.pdf | grep -i "^link:"

4. Across the whole site with a crawler. In Screaming Frog, open Configuration > Spider > Crawl and tick the options to store and crawl hreflang annotations. After the crawl, the Hreflang tab's "Incorrect Language & Region Codes" filter lists the affected pages. Ahrefs and Semrush site audits also report invalid codes.

5. In the code repository, if you have access to the templates:

grep -rn -i -E "en[-_]uk" --include="*.php" --include="*.twig" --include="*.liquid" --include="*.ts" --include="*.tsx" --include="*.js" --include="*.json" --include="*.yml" .

Correct result: the British version is announced as hreflang="en-GB" everywhere, and no reserved code appears.

How to implement

Before you start

Tell apart three things that are often confused:

Element Correct example for the United Kingdom What is free
hreflang value en-GB Nothing: ISO code required
HTML lang attribute <html lang="en-GB"> Nothing: same convention
URL path or domain /uk/, /en-gb/, example.co.uk Everything: the URL is not read as a code
Open Graph og:locale en_GB (with an underscore) Format specific to Open Graph

You can therefore keep a /uk/ folder or a .co.uk domain: only the value of the hreflang attribute needs to change. Do not use en-EU for a "European" version either: EU is reserved and has no effect. To target several English-speaking countries in Europe, annotate one version per country (en-IE, en-MT) or an en version with no region.

Replace the value everywhere at once: in the HTML, in the sitemap and in the headers. One method fixed and the other not produces contradictory annotations (see check consistency across HTML, HTTP header and sitemap methods if combined (opens in a new tab)).

Warning: hreflang="en-GB" must appear on every page in the group, including in the annotations of the French or American versions that point to the British page. Fixing only the British page leaves inconsistent return links.

HTML

A compliant block in the <head> of each version, identical on every page in the group:

<link rel="alternate" hreflang="en-GB" href="https://example.com/uk/pricing/">
<link rel="alternate" hreflang="en-US" href="https://example.com/us/pricing/">
<link rel="alternate" hreflang="fr-FR" href="https://example.com/fr/tarifs/">
<link rel="alternate" hreflang="x-default" href="https://example.com/pricing/">

On the British page, also declare the document language: <html lang="en-GB">.

XML sitemap

<url>
  <loc>https://example.com/uk/pricing/</loc>
  <xhtml:link rel="alternate" hreflang="en-GB" href="https://example.com/uk/pricing/"/>
  <xhtml:link rel="alternate" hreflang="en-US" href="https://example.com/us/pricing/"/>
  <xhtml:link rel="alternate" hreflang="fr-FR" href="https://example.com/fr/tarifs/"/>
</url>

If the sitemap is generated, fix the source (language mapping table, plugin setting), not the output file. Then resubmit it in Search Console's Sitemaps report.

Apache

Versions Apache 2.4.

If Link headers annotate PDFs, look for the value in the configuration and in .htaccess:

sudo grep -rn -i "hreflang" /etc/apache2/ /var/www/ 2>/dev/null | grep -i "uk"

Replace hreflang=\"en-UK\" with hreflang=\"en-GB\" in the Header set Link directive, then reload with sudo apachectl configtest && sudo systemctl reload apache2.

Nginx

Versions Nginx 1.18 and later.

Same search in /etc/nginx/ (sudo grep -rn -i "hreflang" /etc/nginx/), fix the add_header Link directive, then run sudo nginx -t && sudo systemctl reload nginx.

WordPress

Versions WordPress 6.4 to 7.1, with Polylang 3.0 and later, WPML 4.5 and later, TranslatePress or Weglot (interfaces as of November 2026).

WordPress does not write hreflang annotations itself; multilingual plugins do. Yoast SEO and Rank Math do not produce any.

  • Polylang: the hreflang code is derived from the language's WordPress locale, with the underscore turned into a hyphen. In Languages > Languages, the language must use the en_GB locale (English UK). A language created with a wrong custom locale gives a wrong hreflang: edit it.
  • WPML: in WPML > Languages, open "Edit Languages". Each language has an hreflang field separate from the language code and the locale: enter en-GB for British English and save. A sitemap plugin may read the language code rather than this field: check the sitemap too.
  • TranslatePress: the "English (UK)" language uses the en_GB locale. Check in Settings > TranslatePress that this is the active one, and not a custom language.
  • Weglot: codes are managed in the Weglot dashboard. Check the source code after any language change.

Then clear the page cache (plugin, server, CDN) and run the curl test again.

Shopify

Versions Shopify admin, all plans, November 2026.

Shopify generates the annotations from the markets and languages configured in the Markets section of the admin, with ISO country codes: a United Kingdom market produces en-GB with no setting required. The risk comes from a theme that adds its own tags. Search for hreflang in Online Store > Themes > … > Edit code, particularly in layout/theme.liquid and the SEO snippets: remove the hard-coded tags, or fix the value if you have turned off the automatic tags in Online Store > Preferences.

Drupal

Versions Drupal 10 and 11.

The hreflang code is the language code defined in Configuration > Regional and language > Languages (/admin/config/regional/language). The predefined "English, British" language uses en-gb. If a custom language was created with the en-uk code, add the predefined language, migrate the content to it, then delete the old one: an existing language's code generally cannot be changed. The URL prefix (Detection and selection > URL) can stay uk; it is independent of the code.

Laravel

Versions Laravel 10 to 13: the code does not depend on the version.

Separate the application locale, the URL prefix and the hreflang code in a single mapping table:

// config/app.php
'supported_locales' => [
    'fr' => ['prefix' => 'fr', 'hreflang' => 'fr-FR'],
    'en_GB' => ['prefix' => 'uk', 'hreflang' => 'en-GB'],
    'en_US' => ['prefix' => 'us', 'hreflang' => 'en-US'],
],

Add a test that rejects reserved codes, so the error does not come back:

public function test_hreflang_codes_use_assigned_iso_codes(): void
{
    $reservedRegions = ['UK', 'EU', 'UN'];

    foreach (config('app.supported_locales') as $locale) {
        [$language, $region] = array_pad(explode('-', $locale['hreflang']), 2, null);

        $this->assertMatchesRegularExpression('/^[a-z]{2}$/', $language);

        if ($region === null) {
            continue;
        }

        $this->assertMatchesRegularExpression('/^[A-Z]{2}$/', $region);
        $this->assertNotContains($region, $reservedRegions);
    }
}

The Blade template then reads hreflang from this table, never the raw locale (en_GB contains an underscore, which is invalid in hreflang).

Next.js

Versions Next.js 15 and 16 (App Router).

Next.js does not add hreflang annotations on its own: they come from alternates.languages in the metadata. The keys of this object become the hreflang values:

// app/[locale]/pricing/page.tsx
import type { Metadata } from 'next';

export const metadata: Metadata = {
  metadataBase: new URL('https://example.com'),
  alternates: {
    canonical: '/uk/pricing',
    languages: {
      'en-GB': '/uk/pricing',
      'en-US': '/us/pricing',
      'fr-FR': '/fr/tarifs',
    },
  },
};

If the project uses a library such as next-intl with locales named uk or en-uk, keep those names for the URLs but go through a mapping table to en-GB for the metadata.

Common mistakes

  • Copying the country domain: .co.uk gives en-UK, .jp gives jp. The hreflang code does not follow the domain.
  • Using en-EU for a European version: EU is reserved and has no effect in Google.
  • Fixing the HTML and forgetting the sitemap, or the reverse: the two sources contradict each other.
  • Copying og:locale (en_GB, with an underscore) into the hreflang attribute.
  • Fixing only the British page: the other versions in the group still point to it with en-UK.
  • Forgetting to purge the caches: the fixed HTML does not go out as long as the page cache serves the old version.
  • Changing the URLs as well for no reason: /uk/ can stay, and a URL change requires redirects.

Frequently asked questions

Why is en-UK not valid in hreflang?

The United Kingdom's official country code in the ISO 3166-1 alpha-2 standard is GB. The UK code is only reserved there at the request of the United Kingdom, without being assigned. Google only supports assigned codes and ignores the region part of a reserved code: a page annotated en-UK loses its British targeting. Use en-GB in the hreflang attribute, even if your URLs contain /uk/ or a .co.uk domain.

Should URLs be changed to /en-gb/ if the site uses /uk/?

No. The path or domain of a URL is not interpreted as a language or country code: a /uk/ folder or a .co.uk domain remain perfectly valid. Only the value of the hreflang attribute, and the HTML lang attribute, need to use en-GB. Changing the URLs would require redirects and a reindexing period with no benefit at all for targeting.

en-GB or en-gb: does case matter?

No, Google states that the hreflang value is not case-sensitive: en-GB, en-gb and EN-GB are read the same way. The most widespread convention writes the language in lowercase and the region in uppercase, en-GB, which makes review easier. Choose one form and apply it everywhere, in the HTML, the sitemap and the headers, to simplify automated comparisons.

Can you use en-EU to target the whole of Europe?

No. EU is one of the reserved codes that Google cites as having no effect in hreflang annotations, along with UK and UN. There is no region code for a group of countries. To target several English-speaking countries in Europe, create one annotation per country, for example en-IE and en-MT pointing to the same URL, or use an en version with no region.

Updated on

Topic checklist (PDF)

And now?

In the “Hreflang and regional variants” topic

  1. Implement hreflang for equivalent pages
  2. Check reciprocity
  3. Include the self-referencing annotation
  4. Use absolute URLs
  5. Validate ISO 639-1 language codes
  6. Validate ISO 3166-1 Alpha-2 country codes
  7. Use en-GB rather than en-UK
  8. Use x-default if relevant
  9. Check that targets return HTTP 200
  10. Check that targets are indexable
  11. Exclude redirects and nonexistent pages
  12. Align hreflang and canonical
  13. Automate annotations through the CMS
  14. Update annotations when a translation is removed
  15. Use HTTP headers for PDFs if needed
  16. Check consistency across HTML, HTTP header and sitemap methods if combined
  17. Test same-language variants for different countries