Hreflang Tag Generator

Generate correct hreflang tags for a page that exists in several languages or country versions. Add each version once, and the tool builds the full, reciprocal set of tags, including x-default, for your HTML head or your XML sitemap. It also checks for invalid language and region codes.


  

What is hreflang?

Hreflang is an HTML attribute that tells search engines which language and, optionally, which country each version of a page is meant for. If you have an English page, a French page and a Nigeria-specific English page about the same topic, hreflang helps Google show the right one to each searcher. A user in Paris gets the French page, a user in Lagos gets the Nigerian page, and everyone else gets the default.

Hreflang does not boost rankings by itself. It stops your language versions from competing with each other, and it prevents visitors from landing on a page in the wrong language. Both of these improve the experience and the click-through rate.

How hreflang codes work

  • The first part is a language code from ISO 639-1, such as en, fr, yo or ha. It is required.
  • The optional second part is a region code from ISO 3166-1 Alpha 2, such as NG, GB or US. It is written after a hyphen: en-NG.
  • You cannot use a region on its own. NG alone is invalid, but en-NG is correct.
  • x-default marks the fallback page for everyone else, often a language selector or your main international page.

The three rules that break most hreflang setups

  1. Tags must be reciprocal. If page A points to page B, page B must point back to page A. That is why this tool gives you one identical block to place on every version.
  2. Each page must reference itself. The block includes the page's own URL, and that is correct.
  3. Use full, canonical URLs. Hreflang URLs should be the canonical, indexable version of each page, never a redirect or a noindex page.

HTML tags or sitemap?

Both methods are equally valid for Google. HTML link tags in the <head> are easiest for a small number of pages. The XML sitemap method is better for large sites, because you keep all the annotations in one file instead of editing every page. Bing gives more weight to the content-language meta tag and the lang attribute, so set those correctly too.

Frequently asked questions

Do I need hreflang for a site in one language?

No. Hreflang is only for sites with equivalent pages in more than one language or for more than one country.

Can I use hreflang on Blogger?

Blogger has no built-in option, but you can add the link tags to your theme's head section for specific pages using conditional tags. For most Blogger sites, running separate blogs per language and linking between them is simpler.

How do I check my hreflang tags?

Use the URL Inspection tool in Google Search Console to see how Google reads a page, and check that every version links back to the others.