Hreflang Tag Generator
Generate hreflang tags for multilingual and multiregional websites. Supports HTML link tags, HTTP headers, and XML sitemap formats with built-in validation and smart URL auto-fill.
<link rel="alternate" hreflang="en-us" href="https://example.com/" /> <link rel="alternate" hreflang="en-gb" href="https://example.co.uk/" /> <link rel="alternate" hreflang="en-au" href="https://example.com.au/" /> <link rel="alternate" hreflang="x-default" href="https://example.com/" />
Link: <https://example.com/>; rel="alternate"; hreflang="en-us",
<https://example.co.uk/>; rel="alternate"; hreflang="en-gb",
<https://example.com.au/>; rel="alternate"; hreflang="en-au",
<https://example.com/>; rel="alternate"; hreflang="x-default"
<?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/</loc>
<xhtml:link rel="alternate" hreflang="en-us"
href="https://example.com/" />
<xhtml:link rel="alternate" hreflang="en-gb"
href="https://example.co.uk/" />
<xhtml:link rel="alternate" hreflang="en-au"
href="https://example.com.au/" />
<xhtml:link rel="alternate" hreflang="x-default"
href="https://example.com/" />
</url>
<url>
<loc>https://example.co.uk/</loc>
<xhtml:link rel="alternate" hreflang="en-us"
href="https://example.com/" />
<xhtml:link rel="alternate" hreflang="en-gb"
href="https://example.co.uk/" />
<xhtml:link rel="alternate" hreflang="en-au"
href="https://example.com.au/" />
<xhtml:link rel="alternate" hreflang="x-default"
href="https://example.com/" />
</url>
<url>
<loc>https://example.com.au/</loc>
<xhtml:link rel="alternate" hreflang="en-us"
href="https://example.com/" />
<xhtml:link rel="alternate" hreflang="en-gb"
href="https://example.co.uk/" />
<xhtml:link rel="alternate" hreflang="en-au"
href="https://example.com.au/" />
<xhtml:link rel="alternate" hreflang="x-default"
href="https://example.com/" />
</url>
</urlset>
Your ad blocker is preventing us from showing ads
MiniWebtool is free because of ads. If this tool helped you, please support us by going Premium (ad‑free + faster tools), or allowlist MiniWebtool.com and reload.
- Allow ads for MiniWebtool.com, then reload
- Or upgrade to Premium (ad‑free)
About Hreflang Tag Generator
The Hreflang Tag Generator creates properly formatted hreflang annotations for multilingual and multiregional websites. It supports three implementation methods — HTML link tags, HTTP response headers, and XML sitemaps — and includes smart URL auto-fill, import from existing markup, language presets, and built-in validation to help you avoid common hreflang mistakes that can hurt your international SEO.
How to Use This Tool
- Add language versions — For each language version of your page, enter the hreflang language-region code (e.g.,
en,es,fr-ca) and the full URL. Use the autocomplete suggestions or type your own code. - Use auto-fill (optional) — Enter a base URL and select "Subdirectory" or "Subdomain" pattern to automatically generate URLs for each language entry.
- Add x-default — Include an
x-defaultentry pointing to your fallback page (usually your primary language version or a language-selector page). - Generate tags — Click "Generate Tags" to produce output in all three formats. Review any validation warnings.
- Copy and implement — Use the tabbed output to copy the format you need. For HTML, paste the tags into the
<head>of every language version. For XML sitemaps, download the file and upload it to your server.
Spain
Engine
hreflang
Spanish page
Understanding Hreflang Attributes
Hreflang is an HTML attribute introduced by Google in 2011 to help webmasters indicate the language and geographic targeting of a webpage. When a site has content in multiple languages or regional variations (e.g., English for the US vs. English for the UK), hreflang tags tell search engines which version to display in search results based on the user's language and location.
The hreflang value follows the format language-region, where:
- Language code — An ISO 639-1 two-letter code (e.g.,
enfor English,esfor Spanish,jafor Japanese) - Region code (optional) — An ISO 3166-1 Alpha 2 country code (e.g.,
usfor United States,gbfor United Kingdom,mxfor Mexico)
Special codes like zh-hans (Simplified Chinese) and zh-hant (Traditional Chinese) use script subtags instead of region codes.
Implementation Methods Compared
HTML Link Tags Most Common
Place <link> elements in the <head> section of each page. Simple to implement and works for most websites.
hreflang="en"
href="https://example.com/" />
Best for: Standard HTML websites with a manageable number of language versions.
HTTP Headers For non-HTML
Send hreflang information in HTTP response headers. Useful for files that don't have an HTML <head>, such as PDFs.
rel="alternate";
hreflang="en"
Best for: PDF files, non-HTML documents, and sites where you can configure server headers.
XML Sitemap For large sites
Add hreflang annotations to your XML sitemap using xhtml:link elements. Ideal for sites with many pages and language versions.
hreflang="en"
href="https://example.com/" />
Best for: Large websites with hundreds or thousands of multilingual pages.
Common Hreflang Mistakes to Avoid
- Missing reciprocal tags: Every page referenced in a hreflang tag must link back to all other language versions. If Page A references Page B, Page B must also reference Page A. Unreciprocated tags are ignored by search engines.
- Missing self-referencing tag: Each page should include a hreflang tag pointing to itself. This confirms to search engines that the page is intentionally part of the hreflang set.
- Forgetting x-default: Always include an
x-defaulttag to handle users whose language/region doesn't match any specified hreflang tag. Without it, search engines have no fallback instruction. - Using wrong language codes: Use ISO 639-1 language codes and ISO 3166-1 Alpha 2 region codes. Common mistakes include using
ukfor English (UK) instead ofen-gb, orjpinstead ofjafor Japanese. - Mixing protocols or domains: All hreflang URLs should use the same protocol (HTTPS preferred) and match the canonical URL exactly. Mismatches between hreflang URLs and canonical tags cause confusion for search engines.
Best Practices
- Always use absolute URLs (including
https://) in hreflang tags, never relative paths. - Include a self-referencing hreflang tag on every page.
- Add the
x-defaulttag pointing to your primary version or language-selector page. - Ensure hreflang URLs match the canonical URL of each page exactly.
- Use only one implementation method per page (don't mix HTML tags with sitemap annotations for the same page).
- Validate hreflang tags regularly using this tool, Google Search Console, or other SEO audit tools.
- For pages targeting the same language in different regions (e.g.,
en-usanden-gb), always include both language and region codes.
Frequently Asked Questions
What are hreflang tags?
Hreflang tags are HTML attributes that tell search engines which language and regional version of a page to show to users. They use the rel="alternate" hreflang="x" attribute to indicate language alternatives, helping search engines serve the correct version to users based on their language and location.
Where should I place hreflang tags?
Hreflang tags can be placed in three locations: in the HTML <head> section as <link> elements, in HTTP response headers, or in an XML sitemap. The HTML head method is most common for standard websites, HTTP headers work well for non-HTML documents like PDFs, and XML sitemaps are ideal for large sites with many language versions.
What is x-default in hreflang?
The x-default value is a special hreflang attribute that designates the default or fallback page for users whose language or region does not match any of the specified hreflang tags. Google recommends always including an x-default tag pointing to your primary language version or a language selector page.
Do hreflang tags need to be reciprocal?
Yes, hreflang tags must be reciprocal (also called bidirectional). If page A links to page B with a hreflang tag, page B must also link back to page A with the corresponding hreflang tag. If the reciprocal link is missing, search engines may ignore the hreflang annotation entirely.
What is the difference between language and region in hreflang?
In hreflang tags, the language code (e.g., en, es, fr) uses ISO 639-1 format and specifies the content language. The optional region code (e.g., us, gb, mx) uses ISO 3166-1 Alpha 2 format and targets a specific country. For example, en-us targets English speakers in the US, while en-gb targets English speakers in the UK.
Reference this content, page, or tool as:
"Hreflang Tag Generator" at https://MiniWebtool.com// from MiniWebtool, https://MiniWebtool.com/
by miniwebtool team. Updated: 2026-03-10