Skip to content

Multi-Region Hreflang XML Generator & Geotargeting Matrix

XML sitemap generator and validation script for multi-region websites. Validates bidirectional reciprocal tags, ISO 639-1 languages, and x-default fallbacks.

By Gordon Geraghty·MIT Licence·Updated: 24 September 2026·INTERMEDIATE
01 Prerequisites & Architecture
Stage 01 Architecture

Multi-Region Bidirectional Hreflang Architecture

Validates bidirectional hreflang return links, ISO 639-1 language codes, ISO 3166-1 alpha-2 country codes, and x-default fallbacks across multi-locale international setups.

Difficulty:Intermediate Engineering
Time:20–30 mins
Required Access & Permissions:
International Site ManagementXML Sitemap Generator Access
STEP 01Next.js i18n Routing
Locale Route TreeRegional paths (/en-au, /en-us, /en-gb, /de)
STEP 02ISO Standard Matrix
ISO Code PairingLanguage + Region validation (en-AU, en-US)
STEP 03Graph Return-Link Check
Bidirectional ValidatorEnsures URL A -> URL B implies URL B -> URL A
STEP 04XML / HTML Markup Output
XML Sitemap & Head TagTurnkey sitemap.xml and HTML link elements
02 Interactive Configurator

Multi-Region Hreflang XML Generator & Geotargeting Matrix Configurator

Worked Example · Deterministic Calculation

Multi-Region Geotargeting — 6-Locale Hreflang Matrix with Bidirectional Validation

International SEO hreflang configuration with XML sitemap and HTML link tags across 6 regional endpoints.

1 Input Parameters & Assumptions

ParameterValueContext & Provenance
Global Fallback (x-default)https://gordongeraghty.com/ x-defaultDefault global routing URL
United States (en-us)https://gordongeraghty.com/us/ en-usTargeted US English locale
United Kingdom (en-gb)https://gordongeraghty.com/uk/ en-gbTargeted UK English locale
Australia (en-au)https://gordongeraghty.com/au/ en-auTargeted Australian English locale
France (fr-fr)https://gordongeraghty.com/fr/ fr-frTargeted French locale
Germany (de-de)https://gordongeraghty.com/de/ de-deTargeted German locale

2 Explicit Mathematical Formula

Reciprocal Return Pairs = N × (N - 1) = 6 × 5 = 30 bidirectional validation checks
Self-Referencing Tag Requirement = 1 per document (6/6 present)
XML Sitemap Tag Volume = 6 <loc> blocks × 6 <xhtml:link> entries each = 36 total XML link entries
Configured Locales: x-default, en-us, en-gb, en-au, fr-fr, de-de

3 Computed Output Metrics

Bidirectional Tag ValidationPASS (30/30)ValidationAll target pages contain valid reciprocal hreflang links pointing back to source
Export Formats SupportedXML / HTML / HTTPProtocolsSitemap XML urlset, HTML <head> tags, and HTTP response headers generated
Computed MetricResultInterpretation & Threshold
Configured Regional Locales6 LocalesTotal international market endpoints defined in matrix
Bidirectional Tag ValidationPASS (30/30) ValidationAll target pages contain valid reciprocal hreflang links pointing back to source
Export Formats SupportedXML / HTML / HTTP ProtocolsSitemap XML urlset, HTML <head> tags, and HTTP response headers generated

Strategic Takeaway & Operational Guidelines

Missing reciprocal tags are the #1 cause of Google ignoring hreflang annotations. Defining the complete 6-locale matrix in XML sitemaps eliminates HTML payload bloat while guaranteeing 100% bidirectional compliance.

INSTRUMENT BOUNDARIES

Multi-Region Hreflang XML Generator & Geotargeting Matrix — Scope & Limitations

Explicit operational boundaries and constraints defining target use cases and out-of-scope scenarios.

Built For (Target Use Cases)

  • Generating bidirectional hreflang tags as XML sitemap entries, HTML link tags, or HTTP headers.
  • Modelling one shared locale-to-URL matrix across several regional page variants.
  • Flagging missing x-default or reciprocal locale entries within that shared list.

Not Built For (Limitations & Out-of-Scope)

  • Validating hreflang tags that actually live on separate real pages across a site.
  • Checking ISO language or country code validity; codes are accepted as typed.
  • Auditing an existing site's hreflang setup; entries are typed in manually, not crawled.

Operational Assumptions & Defaults

  • Reciprocity validation assumes every listed URL shares the identical set of locale entries.
  • New locale codes are lowercased automatically but not checked against ISO code lists.
  • The first entry in the list is used as the XML sitemap's <loc> value.

Multi-Region Hreflang XML Generator & Geotargeting Matrix

International SEO & Geotargeting

Generate bidirectional hreflang tags for XML sitemaps, HTML head tags, and HTTP response headers with automated reciprocity validation and x-default fallback.

Locale URL Mappings (6)

Bidirectional Reciprocity Status
✓ Full Bidirectional Reciprocity Verified
x-defaulthttps://gordongeraghty.com/
en-ushttps://gordongeraghty.com/us/
en-gbhttps://gordongeraghty.com/uk/
en-auhttps://gordongeraghty.com/au/
fr-frhttps://gordongeraghty.com/fr/
de-dehttps://gordongeraghty.com/de/
ISO 639-1 & ISO 3166-1 Alpha-2
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
        xmlns:xhtml="http://www.w3.org/1999/xhtml">
  <url>
    <loc>https://gordongeraghty.com/</loc>
    <xhtml:link rel="alternate" hreflang="x-default" href="https://gordongeraghty.com/" />
    <xhtml:link rel="alternate" hreflang="en-us" href="https://gordongeraghty.com/us/" />
    <xhtml:link rel="alternate" hreflang="en-gb" href="https://gordongeraghty.com/uk/" />
    <xhtml:link rel="alternate" hreflang="en-au" href="https://gordongeraghty.com/au/" />
    <xhtml:link rel="alternate" hreflang="fr-fr" href="https://gordongeraghty.com/fr/" />
    <xhtml:link rel="alternate" hreflang="de-de" href="https://gordongeraghty.com/de/" />
  </url>
</urlset>
Export & Deployment Actions1-click clipboard transfer, shareable URL hash, and local file downloads.

Built by Gordon Geraghty, Head of Performance MediaInternational SEO Transpiler
03 Deployment & Production Recipes

Deploy Hreflang XML Sitemap & Head Tags

Deploy the generated <xhtml:link> sitemap XML block or paste the HTML <link rel="alternate"> tags into your locale layout templates.

Export & Deployment Actions1-click clipboard transfer, shareable URL hash, and local file downloads.

hreflang-sitemap.xmlxml
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
        xmlns:xhtml="http://www.w3.org/1999/xhtml">
  <url>
    <loc>https://example.com/en-au/product</loc>
    <xhtml:link rel="alternate" hreflang="x-default" href="https://example.com/product" />
    <xhtml:link rel="alternate" hreflang="en-au" href="https://example.com/en-au/product" />
    <xhtml:link rel="alternate" hreflang="en-us" href="https://example.com/en-us/product" />
    <xhtml:link rel="alternate" hreflang="en-gb" href="https://example.com/en-gb/product" />
  </url>
</urlset>
generate-hreflang-sitemap.tstypescript
interface HreflangEntry {
  lang: string;
  url: string;
}

export function buildHreflangUrlNode(loc: string, alternates: HreflangEntry[], xDefaultUrl: string): string {
  const links = alternates
    .map((a) => `    <xhtml:link rel="alternate" hreflang="${a.lang}" href="${a.url}" />`)
    .join('\n');
  const xDefault = `    <xhtml:link rel="alternate" hreflang="x-default" href="${xDefaultUrl}" />`;

  return `  <url>
    <loc>${loc}</loc>
${links}
${xDefault}
  </url>`;
}
04 Verification Checklist

Hreflang Bidirectional Return Link QA

Verify that all regional pages cross-reference each other with self-referencing and matching return tags.

Self-Referencing Tag Present on All Pages

Confirm /en-au/ page includes an explicit hreflang="en-au" tag pointing to itself.

Bidirectional Return Links Verified

Verify that if /en-us/ links to /en-gb/, /en-gb/ links back to /en-us/ with identical target URL.

x-default Declared for Country Selector / Global

Ensure x-default tag points to international landing or default IP redirect router page.

Common Hreflang Pitfalls in Multi-Region Stores

The most frequent hreflang defect is missing reciprocal confirmation links. If page A points to page B as its Australian variant, page B must return a reciprocal link pointing back to page A. Storing hreflang in XML sitemaps reduces HTML payload weight and streamlines maintenance.

How to cite and attribute this tool

MIT Licence

This resource is free, open and un-gated under the MIT Open Source Licence. You are encouraged to use, integrate and cite it with attribution:

Geraghty, G. (2026). Multi-Region Hreflang XML Generator & Geotargeting Matrix. Gordon Geraghty Resources Hub. https://gordongeraghty.com/resources/hreflang-configuration-matrix
BibTeX Format
@misc{geraghty_hreflang_configuration_matrix,
  author = {Geraghty, Gordon},
  title = {Multi-Region Hreflang XML Generator & Geotargeting Matrix},
  year = {2026},
  url = {https://gordongeraghty.com/resources/hreflang-configuration-matrix},
  note = {Head of Performance Media, Empire Amplify}
}