← Back to glossary
Sitemap Glossary

What is Hreflang in Sitemaps?

Using the xhtml namespace in sitemaps to specify language and regional URL variants.

Hreflang annotations in sitemaps use the `xhtml` namespace to tell search engines about alternative language or regional versions of a page. This is one of three methods to implement hreflang (the others being HTML link tags and HTTP headers).

For large multilingual sites, sitemaps are often the most practical method because they don't require modifying page HTML. Each `<url>` entry includes `<xhtml:link>` elements for every language variant, including a self-referencing link.

Every URL must list ALL its alternates, and each alternate must reciprocally link back. Missing or non-reciprocal hreflang annotations are one of the most common implementation errors.

Example

<url>
  <loc>https://example.com/en/page</loc>
  <xhtml:link rel="alternate" hreflang="en" href="https://example.com/en/page"/>
  <xhtml:link rel="alternate" hreflang="fr" href="https://example.com/fr/page"/>
  <xhtml:link rel="alternate" hreflang="de" href="https://example.com/de/page"/>
</url>

Work with sitemaps programmatically

SitemapKit's API lets you discover, extract, and parse XML sitemaps from any domain. Get structured JSON data with all sitemap elements including Hreflang in Sitemaps.

Related Terms