Hreflang Tag Generator
Draft reciprocal hreflang annotations for alternate-language pages in HTML, headers, or sitemaps.
Updated
What is the Hreflang Tag Generator?
The Hreflang Tag Generator creates alternate-language annotations for multilingual or multi-regional pages. Hreflang signals help search engines understand relationships between localized versions; they do not guarantee which page will appear for a user.
Hreflang can be provided in page HTML, HTTP headers, or an XML sitemap. It does not prevent duplicate content or guarantee rankings or click-through improvements.
Why hreflang is critical for International SEO
Without hreflang, Google may show the wrong language to users. For example, a German user might see your English page instead of your German page, increasing bounce rate and hurting conversions.
The tool can help draft reciprocal annotations, but it cannot verify that the URLs resolve to the correct localized pages or that the annotations are deployed consistently:
- Reciprocal links: Every page in a cluster must link to all alternates including itself. Our generator creates a separate block for each URL automatically.
- Code formatting: Use language tags in a valid format, such as
enoren-US; the tool formats entered language and region values. - x-default handling: Generates the recommended
x-defaultfallback for unmatched languages or language selectors. - Multiple output methods: Get HTML tags for
<head>, HTTPLink:headers for PDFs and non-HTML files, and XML sitemap blocks ready for Google Search Console. - Validation: Detects duplicate hreflang values, duplicate URLs, mixed http/https, inconsistent trailing slashes, and missing self-references.
Perfect for SEOs, developers, content managers, and site owners running sites in multiple languages like en, de, fr, es, ja, or regional variants like en-US, en-GB, es-ES, es-MX, de-DE, de-AT.
Use the generated output as a draft, and verify the current implementation guidance for your search engine and platform.
How it works
1. Build your language cluster
Add each language/region version of the same page. Select the Language (ISO 639-1, e.g. en, de, fr) and optional Region (ISO 3166-1 alpha-2, e.g. US, DE, GB). Then paste the absolute URL like https://example.com/en-us/. The tool auto-composes the hreflang value as en-US.
You can also use Bulk Import — paste CSV lines like en-US, https://example.com/en-us/ or just a list of URLs and the tool will parse them.
2. Set your x-default
Enter an optional fallback URL, often a language selector or global page. x-default is a signal; it does not guarantee what Google will show. Include it only when appropriate for your site.
3. Choose generation options
- Include self-referencing tag: Add the page's own language/region entry to the alternate set.
- Sort by hreflang: Alphabetical sorting for cleaner code.
- Reciprocal tags for every URL: Generates a block for each page in the cluster. Implement the corresponding set on each alternate page.
4. Copy your preferred format
Use the format switcher:
- HTML: Paste inside
<head>of each page. Use the reciprocal view — copy the block labeledFor: https://...to that specific page. - HTTP Header: Configure the response header on your server or CDN, including for non-HTML resources where appropriate.
- Sitemap XML: Use the generated
xhtml:linkentries in a sitemap following the sitemap protocol. - CSV / JSON: For spreadsheets, translation teams, or programmatic implementation.
Pro Tips
- Always use absolute URLs with
https:// - Keep trailing slashes consistent
- Keep alternate sets consistent across the implementation.
- Google's International Targeting report is no longer available in Search Console; use current Search Console reporting and inspect deployed pages or sitemaps.
Examples
US English, German and French cluster
Generate reciprocal HTML hreflang tags for three language versions with x-default fallback
en-US: https://example.com/en-us/, de-DE: https://example.com/de-de/, fr-FR: https://example.com/fr-fr/, x-default: https://example.com/<link rel="alternate" hreflang="de-DE" href="https://example.com/de-de/" />
<link rel="alternate" hreflang="en-US" href="https://example.com/en-us/" />
<link rel="alternate" hreflang="fr-FR" href="https://example.com/fr-fr/" />
<link rel="alternate" hreflang="x-default" href="https://example.com/" />English US vs UK targeting
Differentiate between US and UK English for regional search results
en-US: https://example.com/us/, en-GB: https://example.com/uk/, x-default: https://example.com/<link rel="alternate" hreflang="en-GB" href="https://example.com/uk/" />
<link rel="alternate" hreflang="en-US" href="https://example.com/us/" />
<link rel="alternate" hreflang="x-default" href="https://example.com/" />Sitemap XML for 4 languages
Create an XML sitemap with xhtml:link hreflang annotations for submission to Search Console
en: https://example.com/en/, es: https://example.com/es/, de: https://example.com/de/, ja: https://example.com/ja/<?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/</loc>
<xhtml:link rel="alternate" hreflang="en" href="https://example.com/en/" />
<xhtml:link rel="alternate" hreflang="es" href="https://example.com/es/" />
</url>
</urlset>Frequently asked questions
What is hreflang and why is it important for SEO?
What is hreflang and why is it important for SEO?
Hreflang is an annotation that indicates the intended language and, optionally, region of an alternate page. It can help search engines understand localized page relationships, but does not guarantee which URL will be shown or prevent duplicate content.
What is x-default and when should I use it?
What is x-default and when should I use it?
x-default can identify a fallback URL for users whose language or region does not match another alternate. It is optional; select a page that serves that purpose rather than adding it to every cluster automatically.
Where do I place hreflang tags — HTML, HTTP header, or sitemap?
Where do I place hreflang tags — HTML, HTTP header, or sitemap?
Hreflang can be provided with HTML <link> elements, HTTP Link: headers, or XML sitemap annotations. Choose an implementation that fits your site and keep the alternate set consistent.
Do hreflang tags need to be reciprocal?
Do hreflang tags need to be reciprocal?
Search engines expect the alternate pages to reference each other, including a self-reference. Missing return links can cause annotations to be ignored. Use the reciprocal output as a checklist, then verify what is actually deployed.
Should I use en-US or en_US format?
Should I use en-US or en_US format?
Use a valid language tag with hyphens, such as en or en-US; underscores are not the standard separator. Follow the supported language-tag format and validate the generated annotations.
What is the difference between language and region targeting?
What is the difference between language and region targeting?
A language code alone like en, de, fr targets all speakers of that language globally. A language-region code like en-GB, en-US, de-AT, fr-CA targets speakers in a specific country. Use en if you have one English version for all, or use en-US + en-GB if you have distinct US and UK content with different pricing, spelling, or shipping.
Can I use hreflang with canonical tags?
Can I use hreflang with canonical tags?
Yes, and you should. Each language version should canonicalize to itself, not to another language. For example, the German page should have <link rel="canonical" href="https://example.com/de-de/"> plus hreflang tags to all alternates. Hreflang is not a replacement for canonical — they work together.
What happens if I make a mistake in my hreflang implementation?
What happens if I make a mistake in my hreflang implementation?
Missing return links, invalid codes, or incorrect URLs can make annotations ineffective. The tool checks selected input issues, but cannot verify deployed pages, language content, or search-engine processing.
Does this tool support bulk generation for many URLs?
Does this tool support bulk generation for many URLs?
Yes. Use Bulk Import to paste up to hundreds of lines in CSV format like en-US, https://example.com/en-us/ or TSV. It parses language codes and URLs, detects zh-Hans and zh-Hant, and builds the full reciprocal sitemap in seconds. You can then download the complete XML sitemap, CSV, or JSON for your dev team.
Related tools
More utilities you might find handy.
Alt Text Checker
Review img alt attributes in pasted HTML for missing values and possible quality issues.
Canonical Tag Generator
Create a canonical link tag from a URL and review selected URL normalizations before use.
Header Tag Analyzer
Review H1–H6 heading structure in pasted HTML and create a readable outline.