Since 2010 · Powering 2M+ tool runs every month
Since 2010
Add to Chrome

My Toolbox

Automatic Mode

No saved tools yet.

Go Premium
Related tools
XML Sitemap GeneratorHTML to Text ConverterAPI TesterConduit Fill CalculatorHTML to Markdown Converter
Home Page > Webmaster Tools

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.

Free to useNo sign-up requiredInstant Results
Hreflang Tag GeneratorTry it now — free ▼
Paste HTML source code containing <link rel="alternate" hreflang="..."> tags.
Language Code URL

Embed Hreflang Tag Generator Widget

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

  1. 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.
  2. Use auto-fill (optional) — Enter a base URL and select "Subdirectory" or "Subdomain" pattern to automatically generate URLs for each language entry.
  3. Add x-default — Include an x-default entry pointing to your fallback page (usually your primary language version or a language-selector page).
  4. Generate tags — Click "Generate Tags" to produce output in all three formats. Review any validation warnings.
  5. 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.
👤
User in
Spain
🔍
Search
Engine
🏷️
Reads
hreflang
🇪🇸
Serves
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., en for English, es for Spanish, ja for Japanese)
  • Region code (optional) — An ISO 3166-1 Alpha 2 country code (e.g., us for United States, gb for United Kingdom, mx for 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.

<link rel="alternate"
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.

Link: <https://example.com/>;
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.

<xhtml:link rel="alternate"
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-default tag 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 uk for English (UK) instead of en-gb, or jp instead of ja for 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-default tag 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-us and en-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/hreflang-tag-generator/ from MiniWebtool, https://MiniWebtool.com/

by miniwebtool team. Updated: 2026-03-10

Webmaster Tools:

Top & Updated:

Meta Tag GeneratorYouTube Tag ExtractorGooglebot Crawl Size CheckerView all →
Home Page > Webmaster Tools > Hreflang Tag Generator