1. Home
  2. Developer
  3. hreflang Tag Generator

hreflang Tag Generator

Build hreflang tags for multilingual pages, with code validation built in.

Runs in your browser · No upload
One line per version: "language-code URL". Separate with a space, tab or comma. Lines starting with # are skipped.

Goes inside the <head> of each page. Every language page must carry the full set of lines, including one for itself.

The fallback page for users whose language is not listed.
Result
<link rel="alternate" hreflang="ko" href="https://example.com/ko/" /> <link rel="alternate" hreflang="en-US" href="https://example.com/en/" /> <link rel="alternate" hreflang="ja" href="https://example.com/ja/" /> <link rel="alternate" hreflang="x-default" href="https://example.com/en/" />

Every language page must point to all the others. Put this whole result on each page unchanged.

How to use

  1. In URL per language, write one line per language version of the same content as language-code URL. Example: ko https://example.com/ko/
  2. Choose an Output type. HTML link tags are the usual choice. Use sitemap XML when you have many pages or cannot edit the head, and the HTTP header for files such as PDFs.
  3. If you have a fallback page, keep Add an x-default line automatically on and pick which language URL it should point to.
  4. Copy the result and put it on every language page, identical on each.

What hreflang does

When you serve the same content in several languages, hreflang tells search engines “the other language versions of this page are here”. It helps show the Korean page to Korean users and the English page to US users, and it reduces the chance that translated pages are treated as duplicates.

<link rel="alternate" hreflang="ko" href="https://example.com/ko/" />
<link rel="alternate" hreflang="en-US" href="https://example.com/en/" />
<link rel="alternate" hreflang="x-default" href="https://example.com/" />

Rules you must follow

  • Point to each other: if page A points to B, B must point back to A, or the pair may be ignored. That is why you put this tool’s whole result on every language page.
  • Include itself: each page’s list must contain its own URL too.
  • Full URLs: use https://example.com/en/, not /en/. Start with http or https.
  • One URL per language code: a code may appear only once. Duplicates are reported as errors.

Writing language and region codes

The format is language or language-region. The language is a two-letter ISO 639-1 code (lowercase) and the region a two-letter ISO 3166-1 code (uppercase). Case is fixed for you.

What you mean Correct code Common mistake
Korean ko kr, or ko-kr (works, but ko is enough if you need no region split)
Japanese ja jp
Chinese Simplified / Traditional zh-Hans / zh-Hant cn, or only zh-cn
British English en-GB en-UK
US English en-US us
Fallback for other languages x-default left out

A region on its own, such as us, is not a language code and cannot be used. The tool spots mistakes such as jp, cn and en-UK and tells you the right code. kr is a real ISO code (Kanuri), so it is shown as a warning rather than an error.

The three output types

  • HTML link tags: go inside each page’s <head>. The most common option.
  • Sitemap XML: in sitemap.xml, each <url> lists all language URLs with xhtml:link. Easier to manage when there are many pages. An & in a URL becomes &amp; automatically.
  • HTTP header: in the form Link: <URL>; rel="alternate"; hreflang="ko", .... For non-HTML files such as PDFs.

Use only one of the three. Declaring the same information in several ways only adds the risk of conflicts.

FAQ

Is x-default required?

No, but it is recommended. It names the page to show when no version matches the user’s language, such as a language picker or an English page.

Should I use ko or ko-KR for a Korean page?

If you have a single Korean page, ko is enough. Add a region like ko-KR only when you build separate regional Korean versions.

How far are language codes checked?

The language part is checked against the two-letter ISO 639-1 list. Three-letter codes such as fil are checked for format only, and so are region codes.

Can I use it together with canonical?

Yes. Each language page normally points to itself as canonical. If you canonicalize translations to one language, hreflang is ignored.

Are my URLs sent anywhere?

No. URLs are processed only in your browser and are never sent to a server.

Can't find the tool you need?

Tell us what you want to do. We build the most requested tools first.