Hreflang Generator
Build correct hreflang tags for a multilingual page. Add one row per language version with its language code and full URL, plus an x-default row for the fallback page, and copy the ready to paste HTML snippet or the XML sitemap entry. The output updates as you type.
Your language versions
Enter a language code and a full URL in each row.
Your hreflang tags
XML sitemap entry
Worked Example
A page with an English version at https://example.com/en/, a Spanish version at https://example.com/es/, and a fallback page at https://example.com/ needs three tags. The English row gives a link tag with hreflang set to en and href set to https://example.com/en/, the Spanish row gives a link tag with hreflang set to es and href set to https://example.com/es/, and the x-default row gives a link tag with hreflang set to x-default and href set to https://example.com/. Paste all three tags in the head of every version of the page, including the fallback page itself, so search engines can match each visitor with the right language.
Common Mistakes
Using the wrong language code. Use the two letter ISO code in lower case, such as en, es, or fr. Add the region in upper case only when the page truly targets one region, such as en-US or es-MX. A code like EN or english is not valid.
Leaving out the self reference. Every version of the page must list itself as well as the other versions. A page that lists only the other languages, and not its own URL, gives search engines an incomplete set.
Pointing hreflang at a redirect or a broken URL. Each URL must return a 200 status and must be the canonical version of that language page. A tag that points at a page which redirects, or at a 404, is ignored.
Forgetting x-default. The x-default row tells search engines which page to show when no language version matches the visitor. Without it, visitors whose language has no version may land on the wrong page.
Related Tools
Build redirect rules with the Htaccess Redirect Generator, make an llms.txt file with the LLMs.txt Generator, build an SPF record with the SPF Record Builder, check email authentication with the DMARC Record Builder, or browse every calculator in the Tools hub.
Frequently Asked Questions
What is hreflang?
Hreflang is a tag that tells search engines which language and region a page is written for, and which other versions of the same page exist. It helps Google show the English page to English speakers and the Spanish page to Spanish speakers instead of mixing them up.
Where do I paste the hreflang tags?
Paste the full set of tags in the head section of every language version of the page, including the page itself. Each version carries the same set, so every page points at all the others.
What is x-default?
X-default is a special hreflang value for the fallback page, usually a language selector or the main homepage, shown to visitors whose language has no matching version. It is optional, but it is good practice on multilingual sites.
Can I use hreflang in a sitemap instead?
Yes. The XML sitemap entry this tool builds lists the same language versions inside a url block. Use either the HTML tags or the sitemap method, not both at once for the same page, and add xmlns:xhtml=”http://www.w3.org/1999/xhtml” to your urlset tag when you use the sitemap method.
Do I need a separate tag for each region?
Only when the content truly differs by region. One en tag covers all English speakers. Add en-US and en-GB only when those pages have different prices, spelling, or offers for each country.