Hreflang Generator

Create HTML tags, XML fragments or HTTP Link declarations for equivalent pages. Add an optional x-default and copy each page’s output.

Enter 2–50 unique language or language-region codes and their equivalent page URLs.

Language versions

Screpy’s Hreflang Generator creates HTML tags, XML sitemap fragments or HTTP Link declarations for a group of equivalent language pages. Enter 2–50 supported language codes and their URLs, choose a format, then copy or download the output for each page. The generator prepares the annotations from your values; it does not visit the URLs, install the code or confirm that the published pages link back to each other.

Prepare one group of equivalent pages

Use one run for versions of the same page: the same product, article or service in different languages or markets. A French homepage and an English product page do not become equivalents because they share a domain. Repeat the process for the next content item instead of putting every translated URL on the site into one group.

For an illustrative product with English and Turkish versions, prepare these values:

Field Value Purpose
Language and URL en — https://example.com/en/blue-shirt/ English product page
Language and URL tr — https://example.com/tr/mavi-gomlek/ Equivalent Turkish product page
Optional x-default URL https://example.com/choose-language/ A suitable selection destination

Translated slugs can differ. Copy each intended public URL rather than building it by changing a language folder. Include the complete HTTP or HTTPS address and keep the host, path and trailing slash consistent with the destination you intend to publish. Credentials in URLs are not accepted. The form removes fragments such as #details, so use page addresses rather than section links.

Choose supported language codes

This hreflang generator accepts a two-letter language such as en, tr or de, optionally followed by a supported two-letter region, such as en-GB or pt-BR. Use en when the page serves English readers generally; use a regional code when you actually maintain that regional version. A country on its own, such as GB, is not a language designation.

Each regular row needs a different code. en-US and en-us count as the same input, so changing capitalization does not create another version. Generated codes use lowercase for the language and uppercase for the region. Review the values before copying, especially the difference between the language uk and the region GB for the United Kingdom.

The form supports language and language-region codes only. It does not accept script combinations such as zh-Hant, even though Google supports script annotations in appropriate cases. If your implementation needs those combinations, prepare them outside this generator. An accepted code also says nothing about whether the page’s actual text matches that language.

Decide whether to add x-default

An x-default URL identifies a destination for users whose language or region is not otherwise covered. A language selector can serve that purpose, or you can choose an existing page as the default. Google’s explanation of x-default describes both options. Choose a destination useful for this group of pages; do not send every product’s unmatched visitors to an unrelated page merely to fill the field.

The field is optional. Leaving it empty adds no default annotation. Supplying a URL adds hreflang="x-default" to every generated set; it does not create a browser redirect or a language-selection interface.

For the two language rows above, adding the selector produces two page output blocks with three alternates each: en, tr and x-default. It does not create a third block for the selector. If the default is a separate page, configure its corresponding annotations yourself. If it is already one of the regular page URLs, that page already has a generated block. Check this distinction before assuming every destination has installation code.

Select HTML or HTTP Link output

Choose the format you can maintain wherever this group’s pages are served. You do not need to generate all three just because they are available.

Format Installation point What you receive
HTML Each page’s <head> A set of <link> elements
HTTP Link Each page’s HTTP response A Link: header declaration
XML A language-aware sitemap A <url> fragment for each regular page

For HTML, the illustrative group produces this set, which belongs inside the head of both product pages:

<link rel="alternate" hreflang="en" href="https://example.com/en/blue-shirt/" />
<link rel="alternate" hreflang="tr" href="https://example.com/tr/mavi-gomlek/" />
<link rel="alternate" hreflang="x-default" href="https://example.com/choose-language/" />

The English page includes itself and the Turkish page; the Turkish page receives that same set. In a CMS, use the template or field controlling the head. Pasting the tags into an article’s visible body is not the intended installation.

HTTP Link output belongs in the response headers, configured through your publishing system or server. It is useful for documents such as PDFs that have no HTML head. Copy the whole declaration, not just a URL, and inspect the actual response after installation. A downloaded text file does not change a response by itself. Keep existing unrelated header declarations intact when adding the alternate links.

Turn XML fragments into a sitemap

The XML download is a page fragment, not a complete sitemap ready for submission. Each block supplies a <loc> for its regular input page and repeats the alternates as <xhtml:link> elements. Add those blocks to a sitemap with both the sitemap and XHTML namespaces.

For the same-host example, a complete two-page file would look like this:

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
        xmlns:xhtml="http://www.w3.org/1999/xhtml">
  <url>
    <loc>https://example.com/en/blue-shirt/</loc>
    <xhtml:link rel="alternate" hreflang="en" href="https://example.com/en/blue-shirt/" />
    <xhtml:link rel="alternate" hreflang="tr" href="https://example.com/tr/mavi-gomlek/" />
    <xhtml:link rel="alternate" hreflang="x-default" href="https://example.com/choose-language/" />
  </url>
  <url>
    <loc>https://example.com/tr/mavi-gomlek/</loc>
    <xhtml:link rel="alternate" hreflang="en" href="https://example.com/en/blue-shirt/" />
    <xhtml:link rel="alternate" hreflang="tr" href="https://example.com/tr/mavi-gomlek/" />
    <xhtml:link rel="alternate" hreflang="x-default" href="https://example.com/choose-language/" />
  </url>
</urlset>

The two <loc> values differ; their alternate sets match. When adding fragments to an existing file, keep one enclosing <urlset> rather than nesting complete documents. Replace the example URLs with your own and preserve XML escaping such as &amp; in query strings. Publish the file at a location covering its listed pages; this example fits a root sitemap on example.com.

Use Google’s sitemap hreflang instructions for namespace and hosting requirements. The generator’s separate downloads do not assemble, host or submit that sitemap for you.

Verify the installed annotations

A generated result shows what the supplied values produce, not what visitors or crawlers receive. After installation, compare the published pages with the intended group:

  • Check that each alternate address opens the intended language page, rather than an error, old URL or unrelated destination.
  • For HTML or headers, inspect every regular page’s actual annotations, including its self-reference and links back to the other versions.
  • For XML, inspect the published sitemap itself: the wrapper, each <loc> and its full alternate set.
  • Review canonical tags alongside alternates. Google’s canonical guidance recommends a canonical in the same language where available. Do not automatically point every translation’s canonical at the English page.

Use Hreflang Tags Tester to inspect deployed HTML and HTTP declarations. That checker does not validate sitemap annotations or JavaScript-rendered tags. If preferred URLs disagree with the group, examine them with Canonical Tag Checker.

When a translation moves or disappears, update the group wherever you installed it. Generating a fresh set without replacing the old published annotations leaves the old relationship in place. Hreflang helps describe equivalent versions; it does not translate content or guarantee indexing, rankings or that Google will always display a particular URL.

Frequently asked questions

Create HTML tags, XML fragments or HTTP Link declarations for equivalent pages. Add an optional x-default and copy each page’s output.

Is the XML download a complete sitemap?

No. Each download is a url fragment for one regular input page. Combine the fragments in a sitemap with the sitemap and XHTML namespaces, check its hosting scope, and publish it through your own system.

Can I generate script codes such as zh-Hant?

This generator accepts supported two-letter languages and optional two-letter regions, such as en and en-GB. Script combinations such as zh-Hant are outside its input schema, even though Google supports them in appropriate implementations.

Does x-default create another page output block?

No. It adds an alternate to every regular page’s set. Two regular rows plus x-default produce two output blocks with three alternates each. A separate default page needs its annotations configured separately.

Where do I install the generated hreflang?

Place HTML annotations in each page's head, HTTP Link annotations in its response headers, or XML fragments in a complete sitemap. Keep the alternate set consistent.

Does generating hreflang check my live pages?

No. It produces annotations from your inputs without fetching URLs, verifying their language or checking deployed return links. After installation, inspect the actual pages; Hreflang Tags Tester checks HTML and HTTP declarations, not sitemap annotations or JavaScript-rendered tags.