Back to Blog
Technical SEO

How to Implement Hreflang Tags: Step-by-Step Guide

Step-by-step instructions to implement hreflang tags correctly for multilingual and multi‑regional sites. Examples, testing, and common fixes.

June 7, 2026
13 min read
Share:
SEO specialist arranging URL mapping with sticky notes to plan how to implement hreflang tags

Implementing hreflang correctly prevents search engines from serving the wrong language or regional page to users — and can restore traffic lost to duplicate or mis-targeted pages. This guide shows exactly how to implement hreflang tags, from the inventory you need before starting to code examples, validation checks, and action-by-action fixes. Read this to learn the practical steps, real code snippets, and the checks to run after deployment so localized search visibility actually improves.

TL;DR:

  • Inventory first: map every localized URL (example: 200 product pages × 3 locales = 600 URLs) so you know scale before you start.

  • Use the right method: HTML rel="alternate" for CMS pages, HTTP headers for PDFs/binaries, and XML sitemap hreflang for very large or programmatic sites.

  • Validate and monitor: run automated audits weekly (large sites) or monthly (small sites), fix reciprocity and canonical conflicts first, then language-code issues.

Step 1: Prepare Your Site and Assets (prerequisites)

Before changing templates or sitemaps, build a clear inventory. That list will guide which implementation method and rollout approach work best.

What to gather

  • Sitemap exports or crawl CSVs from Screaming Frog, Sitebulb, or your CMS (one row per URL).

  • Counts: number of pages per language/locale (for example, 200 product pages × 3 locales = 600 localized pages).

  • Your canonical URL policy (preferred absolute URL format).

  • CMS/template access and a developer contact for server/header edits.

  • Redirect maps and any CDN or caching rules that could rewrite language paths.

Standards to follow

  • Use ISO codes: ISO 639-1 for languages (e.g., fr, en) and ISO 3166-1 alpha-2 for countries (e.g., CA, FR). Use language-only for broad targeting (fr) and locale codes for region-specific pages (fr-CA).

  • Follow W3C and Google Search Central guidance on hreflang syntax and reciprocal references.

Practical checks to run now

  • Crawl a sample of your pages and confirm 200 responses and correct canonical tags. If pages return 301/302, fix those first.

  • Run a robots.txt and meta-robots check for language pages so search engines can crawl localized versions.

  • If indexing has problems, follow steps in the fix indexing issues guide before implementing hreflang.

Why this matters If you skip inventory, you can deploy partial tags that create more problems than they fix — missing reciprocals, bad codes, and canonical conflicts. A clear scope prevents rework and prioritizes high-impact pages for your first rollout.

Also see Weglot’s practical recommendations on implementing hreflang tags for more best-practice context: Weglot's guide to hreflang tag best practices.

Audit Tips and Tools

  • Export a sitemap or crawl and pivot by language folder or query parameter.

  • Use spreadsheets to build a mapping table (columns: language, region, localized URL, canonical URL, template path, owner).

  • Tag high-traffic and conversion pages for first priority.

Step 2: Map Languages, Regions, and Target Urls

Create a single authoritative mapping table that lists every language/region combination and the corresponding canonical URL. This table is the source of truth for templates, sitemaps, and automation.

How to build the table

  • Columns: language (ISO 639-1), region (ISO 3166-1 alpha-2, optional), locale code (language-region or language), canonical URL, page type (homepage, product, blog), and owner.

  • Example rows (plain text):

  • En — — — /en/
  • Fr — CA — fr-CA — /fr-ca/
  • Fr — — fr — /fr/

Decide on X-default and Fallbacks

  • Use x-default for a generic landing or language selector page that isn’t region-specific (commonly the root /).

  • If you have language-only and region variants, list them all in the mapping. For example, include fr and fr-CA if both exist.

Handling homepages and parameters

  • Homepages should include hreflang entries for every variant plus x-default where appropriate.

  • For parameterized URLs (example: ?lang=fr), prefer clean URLs (subfolder or ccTLD) when possible — they're easier to map and maintain.

  • If query strings are unavoidable, normalize them in your mapping and use canonical tags to point to the preferred form.

Scaling strategies for large sites

  • Programmatic approach: generate mapping from a canonical database table or CMS export and feed it into sitemap generators or template logic. For details on programmatic methods, see the programmatic SEO approach.

  • Prioritize: roll out hreflang for the top 10% of pages by traffic or revenue first.

Other content considerations

  • Localize meta descriptions and open graph text along with hreflang entries — see tips in write meta descriptions.

  • Compare hosting strategies briefly: Subfolders (using the main domain) are easiest to manage; Subdomains (using a dedicated subdomain) need DNS and separate properties in Search Console; ccTLDs (example.fr) provide strong geo signals but are costlier.

Note: browsers, search engines, and some CDNs can interact with your mapping. Record any CDN rewrite rules to ensure the canonical URL delivered to crawlers matches your mapping. For large sites, export routing rules from the CDN and reconcile them with your mapping table.

Pick the method that fits your architecture: template edits for site pages, HTTP headers for non-HTML assets, and sitemaps for large or programmatic inventories.

Implementation options and when to use them

  • HTML rel="alternate": Use this when you can edit page templates (CMS pages, blog posts). It’s readable and easy to test in-browser.

  • HTTP header rel="alternate": Use this for PDFs, images, or binary resources where you can’t add HTML head tags. The link goes in the HTTP response header.

  • XML sitemap hreflang: Best for very large sites or when hreflang needs programmatic generation and frequent updates. Sitemaps can list thousands of hreflang mappings without altering page templates.

Benefits and limits

  • HTML tags are easy to maintain in templates but require template edits on every page type.

  • HTTP headers work for non-HTML assets but require server-side control.

  • Sitemaps scale but must be regenerated and submitted; search engines rely on the sitemap update cadence.

Maintenance matrix (short) | Method | Maintenance effort | Best for | Typical failure modes | |—|—|—|—| | HTML rel="alternate" | Medium | CMS pages, single-page edits | Template misses a variant; non-reciprocal links | | HTTP header | Medium | PDFs, binaries | Header formatting errors; missing reciprocity | | XML sitemap | Low (programmatic) | Very large sites | Out-of-date sitemap; wrong URLs in feed |

Embed example video A short demo helps compare all three methods visually. The video below shows side-by-side examples and common errors to watch for.

Automation and tools

Practical decision rule

  • If you own templates and have under a few thousand pages, prefer HTML tags.

  • If you have many programmatic pages (catalogs, marketplaces), generate hreflang via sitemaps.

  • For PDFs and images, add hreflang in HTTP headers.

Step 4: Implement Hreflang on Pages and Servers (practical Examples)

This section gives copy-paste-ready snippets, automation tips, and the reciprocity rules you must follow.

HTML rel="alternate" example Add these in the of each localized page. Every variant must reference every other variant (including itself).

<link rel="alternate" href="https://seotakeoff.com/en/" hreflang="en" />
<link rel="alternate" href="https://seotakeoff.com/fr-ca/" hreflang="fr-CA" />
<link rel="alternate" href="https://seotakeoff.com/fr/" hreflang="fr" />
<link rel="alternate" href="https://seotakeoff.com/" hreflang="x-default" />

Key rule: reciprocity — if /en/ lists /fr/, then /fr/ must list /en/ as well. Missing reciprocity is a common error.

HTTP header example (for PDFs or images) Use an HTTP header like this in the server configuration or response: Link: <your website property rel="alternate"; hreflang="fr-CA"

XML sitemap snippet for three locales

<URL>
 <loc>https://seotakeoff.com/en/product-123</loc>
 <xhtml:link rel="alternate" hreflang="en" href="https://seotakeoff.com/en/product-123"/>
 <xhtml:link rel="alternate" hreflang="fr" href="https://seotakeoff.com/fr/product-123"/>
 <xhtml:link rel="alternate" hreflang="fr-CA" href="https://seotakeoff.com/fr-ca/product-123"/>
</URL>

Remember to declare xhtml namespace and submit the sitemap to Search Console. Sitemaps let you centralize mapping for programmatic pages.

Automate Within Templates and CMS

  • Inject the rel="alternate" tags from a canonical URL mapping table or CMS field. Use the same source for templates and sitemap generation.

  • For WordPress or other CMS, add a template partial that outputs hreflang links from custom fields or a language plugin.

  • Consider using deployment hooks to rebuild sitemap hreflang entries on content updates.

Using SEOTakeoff features

  • SEOTakeoff's CMS publishing and internal linking features can help publish localized pages and maintain the cross-language internal links required for users and crawlers. Use the platform’s publishing workflows to push interlinked localized content and ensure internal linking is consistent across locales.

Canonical and hreflang alignment

  • Your canonical tag should point to the preferred version of the localized page; do not point all language variants to a single canonical unless that canonical truly is the same content. Canonical conflicts are a top reason search engines ignore hreflang entries. If canonical and hreflang contradict, fix canonical tags first.

Practical rollout checklist

  1. Implement hreflang snippet in templates for a pilot set of pages.

  2. Push changes to staging and crawl them; verify tags are present and reciprocal.

  3. Deploy to production and submit updated sitemaps (if used).

  4. Monitor via logs and Search Console (next step).

For additional implementation patterns and examples, see Ahrefs' hreflang guide.

CMS Tips

  • Put hreflang logic in a single partial/template to avoid divergence.

  • Bulk-update via CSV import when adding many localized pages.

  • For mobile-first sites, ensure localized tags are present on the mobile template — see mobile SEO tips.

Step 5: Validate, Test, and Monitor Hreflang (site Audit & Ongoing Checks)

Validation is where most teams catch problems. The tasks below are both manual and automated.

Crawl validation checklist

  • Reciprocity: each URL must list every other localized variant including itself.

  • Status codes: every hreflang target must return 200 (or 200-family canonical). Avoid pointing to 404s or temporary redirects.

  • Language codes: confirm ISO formats (lowercase language, uppercase region: fr-CA).

  • Canonical consistency: hreflang target should not be canonicalized to a different language variant.

Tools and steps

  • Curl and fetch: use curl to inspect headers and HTML. Example: run curl -I against the real URL

  • Crawl with Screaming Frog or site audit tools and filter for rel="alternate" or XML hreflang entries.

  • Use Google Search Console’s International Targeting report for basic hreflang errors.

  • Run automated audits: schedule weekly for large sites and monthly for smaller sites.

Automated scheduling

  • SEOTakeoff’s site audit feature can schedule periodic checks and report hreflang mismatches and canonical conflicts. Combine audit alerts with analytics to spot traffic anomalies per locale.

Prioritizing fixes

  • Fix canonical conflicts and 4xx/5xx targets first — they block hreflang from working.

  • Then repair missing reciprocity on high-traffic pages.

  • Tackle language-code formatting issues next.

Monitoring signals to watch

  • Drops in organic traffic by locale in Google Analytics or GA4.

  • New errors in Search Console’s International Targeting report.

  • Crawl errors flagged by automated audits.

Additional reading

Scheduling and content cadence

Step 6: Common Mistakes and Troubleshooting

Below are the most frequent errors and how to triage them quickly.

Missing Reciprocal Hreflang Entries

  • Symptom: Search Console shows mismatch or pages are not served for intended locales.

  • Diagnosis: Crawl one variant and check that each listed hreflang appears on every counterpart.

  • Fix: Update templates or sitemap generation so every variant prints the full set of rel="alternate" links. Re-crawl after deploy.

Incorrect Language/region Codes or Malformed Tags

  • Symptom: Tags exist but Search Console flags invalid hreflang values.

  • Diagnosis: Check case and format (language lowercase, region uppercase, hyphen between).

  • Fix: Normalize codes in your mapping table and regenerate tags.

Conflicts Between Hreflang and Canonical Urls

  • Symptom: hreflang entries point to a URL that canonicalizes to a different locale.

  • Diagnosis: Inspect canonical tags on the target pages and server-side redirects.

  • Fix: Ensure the canonical for each localized page points to itself (or to the correct localized canonical). Prioritize this before mending other hreflang errors.

Regional redirects and geo-targeting problems

  • Symptom: Users or crawlers are redirected away from localized URLs; Google ignores hreflang.

  • Diagnosis: Use curl to inspect 301/302 redirects and server logs to find redirect rules. For CDN-based redirects, check CDN configuration.

  • Fix: Update redirect rules to avoid auto-redirecting crawlers. If geo-IP redirects are a business requirement, serve language selectors instead of hard redirects for ambiguous cases.

Quick diagnostics and commands

  • Use curl to inspect headers:
  • Run curl -I against the real URL (check Link header and status)

  • Use sitemap validators to confirm correct xhtml:link namespace and structure.

  • Review Search Console messages under International Targeting.

Triage flow

  1. Identify high-impact pages (traffic/revenue).

  2. Fix canonical and HTTP status errors first.

  3. Resolve reciprocity issues on those pages.

  4. Normalize codes and fix remaining pages via templated changes or sitemap regeneration.

Off-page remediation

  • If a locale still struggles after hreflang fixes, build local authority via outreach — see tactics in build HARO links.

  • For local-pack visibility and geo-signal troubleshooting, consult rank in the local pack.

Automations and notifications

  • Use simple automations to notify devs when sitemaps change. See Zapier automation ideas for examples.

  • When localized pages are regenerated, trigger a sitemap rebuild and audit run.

Ecommerce-specific pitfalls

  • Product pages with dynamic parameters or variants are common trouble spots. Follow patterns in SEO for ecommerce localization to avoid duplicate listings and incorrect hreflang targets.

The Bottom Line

How to implement hreflang tags correctly starts with a complete mapping and a plan for reciprocity and canonical alignment. Prioritize canonical and HTTP status fixes, choose the implementation method that fits your architecture, and automate audits so regional traffic stays healthy.

Video: HREFLANG Tags Tutorial

For a visual walkthrough of these concepts, check out this helpful video:

Frequently Asked Questions

Does hreflang affect canonicalization and should I include both?

Hreflang and canonical tags serve different purposes: canonical points to the preferred version for indexing, while hreflang signals language/region variants. They must not conflict. If a localized page is canonicalized to a different language variant, the hreflang relationship may be ignored. Fix canonical consistency first: each localized page should usually canonicalize to itself (or to the correct localized canonical).

If you use a sitemap-based hreflang, ensure canonical URLs in the sitemap match the page-level canonical tags so search engines see a consistent mapping.

What should I do if Google ignores my hreflang tags?

Start by checking basics: are the hreflang values properly formatted (ISO codes), are the target pages returning 200 status, and are entries reciprocal? Use curl to inspect headers and a crawl to verify reciprocal rel="alternate" links. Then check Search Console for international targeting errors. Prioritize fixing canonical conflicts and HTTP status issues; these are common causes for ignored hreflang.

If problems persist after correcting these items, re-submit sitemaps, document the changes, and monitor the International Targeting report and traffic for several weeks before calling it resolved.

How do I implement hreflang for thousands of pages?

Generate hreflang programmatically from your CMS or product database and publish entries via XML sitemaps or template partials that pull from a single source of truth. For large catalogs, generate sitemap segments (per 50k-URL limit) with xhtml:link entries and automate sitemap submission. Start by rolling out hreflang to your top-performing pages to limit risk, then expand programmatically.

See the programmatic SEO approach for implementation patterns and use automated audits to catch mapping drift.

Can hreflang cause duplicate content issues?

Hreflang itself does not create duplicate content problems if implemented correctly. It tells search engines which variant to show based on language or region. Duplicate issues arise when canonical tags are missing or incorrect and when multiple variants are indexed without clear hreflang or canonical signals. Ensure each localized page has the correct canonical and hreflang listings and monitor indexing after rollout to confirm that search engines serve the intended variant.

If duplicate content appears in a locale after deployment, check canonical configuration and reciprocity first, then adjust indexing directives or sitemaps as needed.

how to implement hreflang tags

Ready to Scale Your Content?

SEOTakeoff generates SEO-optimized articles just like this one—automatically.

Start Your Free Trial