UtilityKit

500+ fast, free tools. Most run in your browser only; Image & PDF tools upload files to the backend when you run them.

Hreflang Tag Generator

Build alternate link rows for multilingual SEO.

About Hreflang Tag Generator

Incorrect hreflang tags are one of the most common and costly international SEO mistakes — sending French users to the Spanish site, serving UK content to Australian searchers, or triggering duplicate content penalties across regional variants. The Hreflang Tag Generator builds the complete set of reciprocal hreflang link elements for your multilingual or multi-regional site, following Google's hreflang attribute syntax exactly. Enter your page URLs and their language/region codes and the tool produces ready-to-paste HTML <link rel="alternate"> tags for the <head>, XML annotations for your sitemap, and HTTP header syntax for server-side injection. It automatically adds the x-default fallback tag pointing to your default-language page, and it generates the full reciprocal set — every page must reference all others, including itself. Validates codes against ISO 639-1 and ISO 3166-1 lists.

Why use Hreflang Tag Generator

Reciprocal Tag Set Generation

Hreflang only works when every page in the set references all the others, including itself. The tool generates the complete reciprocal set automatically, eliminating the most common implementation error that causes Google to ignore the annotations.

ISO 639-1 and ISO 3166-1 Code Validation

Validates language codes against ISO 639-1 and region codes against ISO 3166-1 alpha-2, catching mistakes like en-UK (invalid — should be en-GB) or zh-CN versus zh-Hans before they are deployed and silently ignored.

x-default Fallback Tag Included

Automatically includes the hreflang="x-default" tag pointing to your designated fallback page, which Google shows to users who do not match any specific language or region variant in your set.

Three Implementation Formats

Outputs HTML <link rel="alternate"> tags for the <head>, XML <xhtml:link> annotations for your sitemap, and Link HTTP header syntax for server-side injection via Caddy, Nginx, or Apache — covering all three methods Google supports.

Multi-Regional Language Handling

Handles both language-only (en, fr, de) and language-region combinations (en-US, en-GB, fr-FR, fr-CA) in the same tag set, which is essential for sites targeting the same language in multiple countries differently.

Copy-Ready Output for CMS and Templates

Generated tags are formatted for direct pasting into HTML templates, sitemap generators, or CMS custom header fields, with correct quoting and indentation so they integrate without reformatting.

How to use Hreflang Tag Generator

  1. Add each URL variant and select its language code (e.g., en) and optional region code (e.g., US, GB) from the dropdowns
  2. Mark one URL as the x-default fallback — this is shown to users whose language/region has no specific match
  3. Click Generate to produce the full reciprocal tag set
  4. Choose your implementation format: HTML <link> tags for <head>, XML for sitemap annotations, or HTTP header syntax
  5. Copy the generated tags and paste them into every page's <head> section — all pages in the set must reference all others
  6. Verify the implementation using Google Search Console's International Targeting report after deployment

When to use Hreflang Tag Generator

  • When launching a multilingual site with separate URLs for each language version
  • When running a multi-regional site that serves the same language differently for different countries (e.g., en-US and en-GB)
  • When Search Console reports hreflang errors and you need to regenerate the correct reciprocal tag set
  • When adding a new language or region to an existing international site and needing to update all existing page sets
  • When auditing an international site to check whether hreflang annotations are correctly implemented
  • When migrating a site to a new URL structure and needing to rebuild hreflang annotations for the new URLs

Examples

English US/GB plus French

Input: https://example.com/en-us/ (en-US), https://example.com/en-gb/ (en-GB), https://example.com/fr/ (fr), x-default → en-US

Output: <link rel="alternate" hreflang="en-US" href="https://example.com/en-us/"> <link rel="alternate" hreflang="en-GB" href="https://example.com/en-gb/"> <link rel="alternate" hreflang="fr" href="https://example.com/fr/"> <link rel="alternate" hreflang="x-default" href="https://example.com/en-us/">

Sitemap XML annotation

Input: https://example.com/ (en), https://example.com/de/ (de)

Output: <url> <loc>https://example.com/</loc> <xhtml:link rel="alternate" hreflang="en" href="https://example.com/"/> <xhtml:link rel="alternate" hreflang="de" href="https://example.com/de/"/> <xhtml:link rel="alternate" hreflang="x-default" href="https://example.com/"/> </url>

Invalid code detection

Input: en-UK

Output: Error: 'UK' is not a valid ISO 3166-1 alpha-2 region code. Did you mean en-GB (United Kingdom)?

Tips

  • Use absolute URLs (including https:// and the full domain) in all hreflang tags — relative URLs are not valid and will be ignored by Google
  • If you use a CDN or proxy that rewrites URLs, verify the hreflang tags reflect the final canonical URL that Google sees, not the internal URL before rewriting
  • For large sites with many language variants, implement hreflang in the sitemap rather than every HTML page to reduce template complexity and risk of missing reciprocal links
  • Re-validate after any URL restructuring — hreflang references to old URLs that redirect rather than resolve directly may cause Google to ignore the annotations
  • Use the same protocol (https vs http) in all hreflang URLs as in your canonical tags to avoid canonical/hreflang mismatches that confuse crawlers

Frequently Asked Questions

What is the x-default hreflang value used for?
x-default signals to Google which page to show users whose browser language or location does not match any specific language/region code in the set. It is typically the English (or primary language) version or a language selector page.
Does every page in a hreflang set need to reference all the others?
Yes. Google requires full reciprocal annotation — if page A references page B, page B must reference page A. Missing reciprocal links cause Google to ignore the annotations entirely for the affected pages. This tool generates the full reciprocal set automatically.
Is en-UK a valid hreflang code?
No. The correct code for English as used in the United Kingdom is en-GB, using ISO 3166-1 alpha-2 for the region. en-UK is a common mistake — Google may interpret it but it is technically invalid and this tool flags it as an error.
Can I use hreflang in a sitemap instead of HTML tags?
Yes. Google supports three implementation methods: HTML <link> tags, sitemap XML annotations, and HTTP response headers. Sitemap implementation is often preferred for large sites because it avoids adding tags to every page template, but all pages in the set must still be referenced in the sitemap.
What happens if my hreflang implementation has errors?
Google silently ignores hreflang annotations it cannot validate, falling back to serving whatever page its algorithm thinks is most relevant. This often means users see the wrong language version, increasing bounce rates and reducing conversion on international pages.
Should I use language-only codes like 'fr' or region-specific like 'fr-FR' and 'fr-CA'?
Use language-only (fr) when you have one French version for all French speakers. Use language-region codes (fr-FR, fr-CA) when you have distinct versions for different countries, such as different prices, products, or spelling conventions.
Does hreflang affect rankings in the targeted region?
Hreflang does not directly boost rankings; it tells Google which URL to show to which users. The correct page appearing in the right regional search results reduces bounce rate and improves engagement signals, which can indirectly support rankings.
How do I verify my hreflang implementation is working?
Check Google Search Console under Settings > International Targeting for hreflang errors. You can also use a hreflang checker crawl tool to verify the reciprocal links are present on all pages, and test by searching from a different country using a VPN.

Explore the category

Glossary

hreflang
An HTML attribute on <link rel="alternate"> tags that specifies the language and optional region of an alternate page URL, telling search engines which version to serve to which users.
x-default
A special hreflang value indicating the fallback page to show users whose language or region does not match any other annotated variant in the set.
Reciprocal Annotation
The requirement that every page in a hreflang set must reference all other pages in the set, including itself. Missing reciprocal links cause Google to ignore the annotations.
ISO 639-1
The international standard for two-letter language codes used in hreflang attributes, such as en for English, fr for French, and de for German.
ISO 3166-1 alpha-2
The international standard for two-letter country codes used in the region portion of hreflang values, such as US, GB, FR, and AU.
International Targeting
Google Search Console's report for sites targeting specific countries or languages, showing hreflang errors, geo-targeting settings, and country-specific search impressions.