Skip to content

Hreflang Generator

Generate one consistent set of escaped HTML alternate links from locale-and-URL rows, including canonical casing and optional x-default fallback.

Privacy: your files never leave your device. All processing happens locally in your browser.

How to use

  1. 1.List every localized page as locale | fully qualified URL, including the current page and an optional x-default fallback.
  2. 2.Generate the complete escaped link block and verify each locale against current supported language and region guidance.
  3. 3.Install the identical set in every alternate page head, then crawl the live pages to confirm self and reciprocal links.

About Hreflang Generator

Hreflang Generator creates HTML link elements for localized or regional versions of equivalent content. Enter one locale and absolute URL per line, separated by a vertical bar. The tool returns one rel=alternate element for each row, ready to place in the head of every page in that language cluster.

Each localized version should publish the same complete set, including a link to itself. Alternate pages should point back to one another. Google documents these self and return links as essential signals; a one-way declaration can be ignored because another site must not be able to claim your page as its alternate unilaterally.

URLs must be fully qualified with http or https, including the host. Relative and scheme-relative references are rejected. Credentials and fragments are also rejected. The browser URL parser normalizes the address, while ampersands and other attribute-sensitive characters are escaped in the generated HTML.

Locale input accepts a two-letter language, an optional four-letter script and an optional two-letter region. Case is canonicalized, so en-us becomes en-US and zh-hant becomes zh-Hant. The special x-default token is accepted for a fallback page when no listed language or region matches the user.

The page checks language-tag shape, not the complete current ISO language and country registries supported by a particular search engine. A structurally tidy code can still be unsupported or inappropriate. Verify every intended language and region against current Google documentation and the actual content audience before deployment.

A country code cannot stand alone in the first position; the first subtag identifies language. Regional targeting belongs after a language, such as fr-CA. Generic language pages such as fr can be useful fallbacks when several country-specific French versions exist. Script subtags can distinguish writing systems such as zh-Hans and zh-Hant.

x-default does not represent a language. It identifies a page intended for users whose settings do not match a listed alternate, often a country selector or generic landing page. Only one x-default row should appear in a set, and duplicate locale values are rejected case-insensitively after normalization.

Hreflang does not translate content, detect language or guarantee a search result. Google may algorithmically identify page language and choose results based on many signals. The tags describe a relationship among substantially equivalent localized pages; they are not substitutes for translated primary content or coherent international architecture.

The generator supports up to 100 rows and requires at least two, including the current page. Each line must contain exactly one separator. Failing the entire set on malformed input prevents a partial output from being copied while silently omitting one country or language version.

Eight standards-aligned fixtures cover generic languages, regional casing, German and French regions, simplified and traditional Chinese script tags, a language-script-region combination and x-default. Additional tests assert exact HTML escaping and reject duplicates, relative URLs, fragments, credentials and incomplete one-row sets.

To use it, inventory every equivalent localized page, include the URL currently being edited and add x-default only when a genuine fallback exists. Generate the tags, install the identical block in each page head and test the delivered HTML for every locale. Confirm each alternate returns a useful 200 page.

Do not combine inconsistent hreflang sets across HTML, HTTP headers and XML sitemaps. Google treats those implementation methods as equivalent, and maintaining several copies can create drift. Choose the method your publishing system can keep complete and synchronized. This tool specifically produces HTML head elements.

After deployment, crawl a sample from every language cluster and compare sets mechanically. The tool cannot access remote pages or prove reciprocal links. Ongoing quality depends on updating all members when a locale is added, removed, redirected or moved to a new canonical URL.

Methodology & sources

Rows are split on one literal |, locale tags are constrained to language plus optional script and region and canonicalized with Intl.getCanonicalLocales, x-default is handled explicitly, URLs are normalized as fragment-free credential-free HTTP(S), and attributes are HTML escaped.

Frequently asked questions

SEO & Webmaster guides

View all