Home SEO Tools Hreflang Generator

Hreflang Tag Generator

Free

Because "just add hreflang" is never just adding hreflang. Technically simple, practically painful. Supports HTML, XML sitemap, and HTTP header formats. Each output gives you the full reciprocal set for every page in the group. Paste it on those pages and you're done. Also works beautifully for showing engineering and product teams exactly how it should be implemented — then kindly asking them to automate it.

URL Groups One group = one page in multiple languages
Output:
Fill in at least one URL and language above
to see your hreflang markup here.

How to use this generator

1
Create a URL group.

One group = one logical page. If you're generating tags for your homepage and your about page, that's two groups.

2
Add a row for each language version.

Enter the full URL (e.g. https://example.com/fr/), then pick a language and, if needed, a region.

3
Set one row as x-default.

This is the fallback for users whose language isn't matched. Usually your main English URL or a language-selector page.

4
Choose your output format.

HTML <link> tags go in your page <head>. XML sitemap entries go in your sitemap file. HTTP headers are for server-level delivery.

5
Copy the code for each page.

Each output block is labelled with its destination URL. Paste the full block onto the corresponding page — every block already contains the complete set of tags for that page.

Important: paste the full code block onto each page listed — not just the tag pointing to that page. Each block contains the complete set of tags for that page, covering all alternates and x-default. Pasting the full block onto every respective page is what makes your hreflang network bidirectional.

What makes correct hreflang hard — and how this tool handles it

Hreflang is one of the most commonly broken international SEO signals. The rules are precise, and a mistake anywhere in the network can cause Google to ignore all your tags. Here are the three requirements that trip people up most often — and what this generator does about each one.

1. Bidirectional linking

If your English page points to your French page, the French page must also point back to the English page — and to every other language version. This has to be true for every page in the group. Miss one direction and Google can reject the entire set.

This generator produces the correct full tag set for each page in a group — every output block includes tags pointing to all sibling pages, not just the one you're generating for. When you paste each block onto its respective page, the bidirectional network is complete. The work of making it bidirectional is yours — pasting the right block onto the right page — but the generator makes sure every block already contains everything it needs.

2. Self-referencing

Each page must include a hreflang tag pointing to itself, alongside the tags pointing to its alternates. It sounds redundant but it's required — Google uses self-references to confirm the page belongs in the group.

Each output block in this generator includes the self-referencing tag for that page. You don't need to add it manually — it's already in the code you copy.

3. The x-default attribute

The x-default tag tells Google which version of your page to show to users whose language or region isn't covered by your other tags. It's not technically required, but Google strongly recommends it — and without it, users in unmatched regions may see the wrong page.

Set the x-default flag on any row in a group and the generator includes hreflang="x-default" in every output block for that group. The validation bar warns you if a group has no x-default set.

Three ways to implement hreflang

Hreflang tags can be delivered to Google in three ways. This generator produces all three formats — switch between them using the tabs in the output panel.

Most common

HTML <link> tags

Place the generated tags inside the <head> section of every page in the group. Works for any standard HTML page.

<head>
  <link rel="alternate"
    hreflang="en"
    href="https://example.com/en/" />
  <link rel="alternate"
    hreflang="fr"
    href="https://example.com/fr/" />
  <link rel="alternate"
    hreflang="x-default"
    href="https://example.com/en/" />
</head>
Large sites

XML Sitemap

Add annotations inside each <url> element. Keeps HTML clean and gives you a single place to manage all alternate URLs. Add xmlns:xhtml to your <urlset> tag.

<urlset
  xmlns:xhtml="...">
  <url>
    <loc>.../en/</loc>
    <xhtml:link
      hreflang="en"
      href=".../en/" />
    <xhtml:link
      hreflang="fr"
      href=".../fr/" />
  </url>
</urlset>
Server-level

HTTP Response Headers

The only option for non-HTML files like PDFs. Also useful for JavaScript-rendered pages where modifying the HTML head is impractical.

# Apache
Header add Link
  '<.../en/>;
   rel="alternate";
   hreflang="en"'

# Nginx
add_header Link
  '<.../en/>;
   rel="alternate";
   hreflang="en"';

Common hreflang mistakes — and how to fix them

MistakeHow to fix it
Missing bidirectional tags Every page in a group must reference every other page. If page A points to page B but page B doesn't point back, Google may ignore all tags in the group. This generator produces the correct full tag set for each page — every output block contains all alternates. Paste each block onto its respective page and the network is complete.
Relative URLs Hreflang href values must be absolute URLs including the protocol (https://). A relative URL like /fr/ will be ignored. The URL input in this generator requires a full URL.
Wrong language or region codes Language codes follow ISO 639-1 (e.g. en, fr, de). Region codes follow ISO 3166-1 alpha-2 (e.g. GB, US). Case doesn't matter — Google accepts en-GB and en-gb equally — but mixing up language and region codes does. Common examples: using uk when you mean the United Kingdom (the correct region code is GB; uk is actually the language code for Ukrainian), or using eng instead of en. This generator's dropdowns use correct codes only.
Missing x-default Omitting x-default means Google has no fallback for users in unmatched regions. It's not a breaking error, but strongly recommended — especially if you have significant traffic from countries not explicitly targeted. The validation bar flags groups missing x-default.
Duplicate lang/region combinations Each language + region combination must appear only once per group. If you have two rows for en-GB, Google won't know which URL to use. The generator shows a red validation error if a duplicate is detected.
Mixed implementations If you implement hreflang in both the HTML <head> and your XML sitemap for the same pages, make sure both are consistent. Mixed or partial implementations can confuse crawlers. Pick one method and use it for all pages in a group.

When do you need hreflang tags?

Hreflang tags should be added to any page that has a language or regional variant — a version of the same page for a different audience. The three main scenarios are:

Hreflang is not needed for pages that only exist in one language and don't have regional variants. Adding it unnecessarily creates maintenance overhead without any SEO benefit.

Frequently asked questions

Does every page on my website need hreflang tags?
Only pages that have language or regional variants need hreflang tags. If a page exists in only one language and has no regional versions, skip it. Adding hreflang to single-language pages with no alternates doesn't improve SEO and adds unnecessary markup.
What is x-default and do I need it?
The x-default attribute identifies the fallback page to show users whose language or region isn't covered by your other hreflang tags. Google doesn't require it, but strongly recommends it. If your site has significant traffic from regions you haven't explicitly targeted — or if you have a language-selector page — x-default is important. Set the x-default flag on one row per group in this generator. The hreflang="x-default" tag is included in every output block for that group.
Do hreflang tags have to be bidirectional?
Yes. If page A lists page B as an alternate, page B must also list page A as an alternate. This rule applies to every page in a group — all pages must reference all other pages. Google validates the entire network before acting on hreflang tags. A broken bidirectional structure is the most common reason hreflang stops working. This generator produces the correct full tag set for each page — every output block includes all alternates.
Can I use an XML sitemap instead of putting tags in the HTML <head>?
Yes. Hreflang can be implemented in the HTML <head>, in an XML sitemap, or via HTTP response headers. All three methods are supported by Google. XML sitemaps are often preferable for large sites — they're easier to manage and keep HTML cleaner. The output panel in this generator includes all three formats; switch between them using the format tabs.
How many URL groups can I create?
There's no limit on the number of groups. Each group represents one logical page (e.g. your homepage, your pricing page, your contact page) with all its language and region variants. Add as many groups as you need in one session.
What happens if my hreflang tags are wrong?
Google may ignore the tags entirely, show the wrong language version to users, or — in cases of conflicting signals — treat the pages as duplicate content. The most common issues are missing bidirectional links, incorrect language or region codes, and missing self-references. This generator's real-time validation flags duplicate lang/region combinations and missing x-default before you copy the output.
Does this tool validate my hreflang tags?
The generator validates your input in real time. It checks for: fewer than two URLs in a group (you need at least two for a valid hreflang set), missing x-default (amber warning), and duplicate language/region combinations within the same group (red error). URL reachability is not checked — the tool doesn't make network requests.
Do I need to include a tag for every language on every page?
Yes. Every page in a hreflang group must carry the full set of alternate tags — including a tag pointing to itself. This is what makes the network valid. This generator's output blocks already include the complete set for each page — just paste the entire block into the relevant page.

Go beyond hreflang tags

Hreflang tells search engines which page to show. Geo Redirect tells your website which page to actually send visitors to — automatically, based on their country, state, or city. Use both together for a complete international targeting strategy.

Sources