Generate your hreflang tags
One line per version: the language or region code, then the URL. This sitemap hreflang generator produces the <link> block for your page head and the sitemap entries, and adds x-default for you.
How to use it
Paste the output into the <head> of every version (the block must be identical on each, including a self-reference), or into each <url> entry of your sitemap. Then run the hreflang check to confirm every version links back.
See a complete two-page hreflang sitemap example and the checks to make before publishing.
Sitemap hreflang generator: two-language example
For equivalent English and German pages, enter en https://example.com/en/shirt and de https://example.com/de/shirt on separate lines. If the English page is also the appropriate fallback, add x-default https://example.com/en/shirt explicitly. The hreflang builder uses that set for both output formats; choose the sitemap output when your publishing process maintains alternates there.
The generated fragment starts with the first page's <loc>https://example.com/en/shirt</loc> and includes an alternate such as <xhtml:link rel="alternate" hreflang="de" href="https://example.com/de/shirt"/>, alongside the English and fallback entries. This is a URL fragment, not a complete sitemap. The enclosing <urlset> must declare xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" and xmlns:xhtml="http://www.w3.org/1999/xhtml".
Create a second <url> record whose <loc> is the German URL and repeat the identical alternate set under it. Every language page needs its own record, including references to itself and the other versions. Check that the destinations are equivalent live pages, publish the complete sitemap, then use hreflang sitemap check to inspect the declarations. Do not paste the single generated fragment as though it covers every language URL.
What the hreflang generator produces
Enter one language or language-region code and URL per line, with at least two versions. The browser form produces two formats from those inputs: link rel=alternate tags for a page head, and an xhtml:link block inside one sitemap URL entry. If you did not enter an x-default row, the generator adds one pointing to the first URL you entered. It also lets you copy or download the outputs.
The generator does not fetch URLs, validate language codes, check redirects, compare page content or test reciprocity. It accepts the text you provide and writes the corresponding attributes. The generated sitemap output is one <url> entry for the first URL with alternates; you must create corresponding entries for the rest of the URL set in a real sitemap.
How to read the two output formats
The head version is a set of <link rel="alternate" hreflang="en-US" href="https://example.com/us/" /> tags. Place equivalent alternate declarations on each version, including a reference to itself. The sitemap version places language alternates under an <xhtml:link> element inside a page's <url> record. Pick one implementation method for the cluster or keep both synchronized; mismatched sets are difficult to maintain.
If x-default is omitted, the generated fallback points to the first input URL. That is a convenience, not a decision about the right default experience. Choose a URL that genuinely serves as a language or region fallback, such as a selector or a broadly suitable landing page. Review the output before copying it into production.
Common hreflang errors
A common issue is using a country code alone when a language code is needed, or swapping the order in a language-region value. Hreflang values use language tags such as en, en-US or fr-CA; URLs must be absolute and point to the intended equivalent page. The form does not validate those values, so compare them with Google's current language and region guidance before deployment.
Another frequent error is publishing the set on only one version. Search engines expect each page in the group to identify the other alternates and itself. Dead URLs, redirects to unrelated pages, missing return references, duplicate codes and a fallback pointed at the wrong market all weaken the cluster. The generator can produce repeated or incorrect inputs without warning because it is not a URL validator.
Steps to deploy the tags safely
First list the real equivalent URLs and their intended language or region. Use one line per version, for example en-GB https://example.com/uk/ and de-DE https://example.com/de/. Generate both outputs, decide whether the first URL is a sensible x-default, and copy only the format your implementation will maintain.
Add the page tags to every localized page template or add the sitemap entries to every relevant URL record. Verify that each URL returns the intended page and that the rendered or raw source contains the correct alternates. Run hreflang check for reciprocal page-tag inspection and hreflang sitemap check when you need to compare page and sitemap declarations. Fix the source template or sitemap generator, not only one output file, if future builds overwrite your changes.
When to use hreflang and related checks
Hreflang is useful when you publish equivalent content for different languages or regional audiences. It helps search engines understand the relationship between those versions; it does not translate content, guarantee a chosen result, or replace localized URLs. If you only have one language and no regional alternatives, adding self-only tags is usually unnecessary.
Use the generator to form the initial tags or sitemap block. Use hreflang checker after publication to inspect declared alternates and sampled return links. If the page version and sitemap disagree, run hreflang sitemap check. If your issue is a particular missing return link, see the reciprocal hreflang fix.