Content SEO

    What Is Hreflang? A Practical Guide

    The attribute that tells Google which language and region each version of a page targets — non-optional for multi-country sites.

    5 min readReviewed Jul 9, 2026

    The attribute that tells Google which language and region each version of a page targets — non-optional for multi-country sites.

    What hreflang does

    Hreflang is an HTML attribute that specifies the language and geographical targeting of a webpage. It is used on websites that serve content in multiple languages or target different regions with the same language. The primary purpose of hreflang is to help search engines like Google serve the correct language or regional URL to users.

    For example, a multinational company might have a website with different versions for its audience in the United States and Canada, both primarily English-speaking, but with some localized content or pricing. It might also have a Spanish version for its audience in Mexico. Hreflang tags would signal to search engines which version of a page is appropriate for users based on their location and language preferences.

    Hreflang is a strong signal, not a hint. When properly implemented, Google respects hreflang declarations and uses them to serve the most relevant page. However, silently ignores broken or incorrectly configured hreflang setups. This means that if hreflang is not set up correctly, it will not influence search results, and Google will default to its standard methods of determining page relevance. This can lead to users seeing a version of a page that is not optimized for their location or language.

    The 3 places to declare hreflang (HTML, sitemap, HTTP header)

    Hreflang declarations can be implemented in three ways: within the HTML <head> section, in an XML sitemap, or via HTTP headers. Best practice recommends choosing one method and using it consistently across the entire site.

    HTML <head>

    This method involves adding <link> tags with the hreflang attribute to the <head> section of each page.

    Here is an example:

    <link rel="alternate" href="https://www.example.com/en-us/" hreflang="en-US" />
    <link rel="alternate" href="https://www.example.com/en-ca/" hreflang="en-CA" />
    <link rel="alternate" href="https://www.example.com/es-mx/" hreflang="es-MX" />
    

    In this example, en-US targets English speakers in the United States, en-CA targets English speakers in Canada, and es-MX targets Spanish speakers in Mexico. Each page must reference itself as well as all its alternate versions.

    XML Sitemap

    Hreflang can also be defined within an XML sitemap. This method is often preferred for large websites because it centralizes all hreflang information, making it easier to manage and update.

    Here is an example of an XML sitemap entry with hreflang:

    <url>
      <loc>https://www.example.com/en-us/</loc>
      <xhtml:link rel="alternate" hreflang="en-US" href="https://www.example.com/en-us/" />
      <xhtml:link rel="alternate" hreflang="en-CA" href="https://www.example.com/en-ca/" />
      <xhtml:link rel="alternate" hreflang="es-MX" href="https://www.example.com/es-mx/" />
    </url>
    

    Each <url> entry includes its <loc> and then a series of <xhtml:link> elements for all its language and region variants, including itself.

    HTTP Header

    For non-HTML files, such as PDFs, hreflang can be specified using HTTP headers.

    Here is an example:

    Link: <https://www.example.com/en-us/>; rel="alternate"; hreflang="en-US",
          <https://www.example.com/en-ca/>; rel="alternate"; hreflang="en-CA",
          <https://www.example.com/es-mx/>; rel="alternate"; hreflang="es-MX"
    

    This method is less common for typical web pages but essential for content that is not served as HTML.

    Return-tag requirements (they must be reciprocal)

    A critical requirement for correctly implemented hreflang is reciprocity, also known as the "return tag" requirement. This means that if page A links to page B with an hreflang annotation, page B must in turn link back to page A with a corresponding hreflang annotation. If this reciprocal linking is not present, Google may ignore the hreflang tags or not interpret them as intended.

    For example, if https://www.example.com/en-us/ declares an alternate version at https://www.example.com/es-mx/, then https://www.example.com/es-mx/ must also declare https://www.example.com/en-us/ as its alternate. This two-way linking confirms the relationship between the localized pages to search engines.

    Failure to implement return tags is a common reason why hreflang setups are silently ignored by search engines.

    x-default for language pickers and fallbacks

    The x-default hreflang value is used to specify a default page when no other language or regional version is a perfect match for a user's settings. It is often used for a language-picker page or a generic fallback page that serves users whose language/region combination does not have a specific localized version.

    For example, if a website has English (en), Spanish (es), and French (fr) versions, but a user from Germany (de) lands on the site, the x-default page would be served.

    Here is an example of how x-default might be implemented alongside other hreflang declarations:

    <link rel="alternate" href="https://www.example.com/en/" hreflang="en" />
    <link rel="alternate" href="https://www.example.com/es/" hreflang="es" />
    <link rel="alternate" href="https://www.example.com/fr/" hreflang="fr" />
    <link rel="alternate" href="https://www.example.com/" hreflang="x-default" />
    

    In this setup, if a user's language and region do not match en, es, or fr, they would be directed to https://www.example.com/, which could be a language selection page or a general international version of the site.

    Common hreflang mistakes

    Misconfigurations in hreflang are common and can result in search engines ignoring the tags. These are some of the most frequent errors:

    <table> <thead> <tr> <th>Mistake</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td>Missing return tags</td> <td>As discussed, each referenced URL must reciprocate the hreflang declaration. Lack of reciprocity causes search engines to invalidate the entire set of hreflang tags for those URLs.</td> </tr> <tr> <td>Incorrect language or region codes</td> <td>Hreflang codes must adhere to ISO 639-1 for language codes and ISO 3166-1 Alpha 2 for optional region codes. Incorrect use (e.g., `en-UK` instead of `en-GB`) will render the tag invalid.</td> </tr> <tr> <td>Relative URLs</td> <td>Hreflang `href` attributes should always use absolute URLs (e.g., `https://www.example.com/en/`) not relative ones (e.g., `/en/`).</td> </tr> <tr> <td>Self-referencing hreflang missing</td> <td>Every page in an hreflang set must include a reference to itself. For example, the US English page must declare its own URL with `hreflang="en-US"`.</td> </tr> <tr> <td>Conflicting signals</td> <td>If different hreflang declarations for the same URL exist (e.g., in HTML and sitemap, or multiple declarations in HTML for the same language/region), search engines may become confused or ignore all signals.</td> </tr> <tr> <td>Broken links in hreflang</td> <td>If an hreflang `href` points to a URL that returns a 404 (Not Found) or other error, the entire hreflang set associated with that link may be compromised.</td> </tr> </tbody> </table>

    How LemRank validates hreflang

    LemRank's site audit feature automatically checks for common hreflang issues to help you maintain a correct implementation.

    When a site audit runs, LemRank's crawler identifies all hreflang declarations across your website, whether they are in the HTML <head>, XML sitemaps, or HTTP headers. The crawler respects your robots.txt directives and operates with a rate limit of 10 requests per second to avoid overwhelming your server. This ensures that the audit runs without negatively impacting your site's performance.

    The audit then validates these declarations against common pitfalls:

    • Reciprocity: It checks if all referenced URLs have a corresponding return tag. If page A links to page B, LemRank verifies that page B also links back to page A.
    • Correct language and region codes: LemRank ensures that all hreflang attribute values adhere to the ISO 639-1 and ISO 3166-1 Alpha 2 standards.
    • Absolute URLs: The audit confirms that all href attributes within hreflang tags use absolute URLs.
    • Self-referencing tags: It verifies that each page includes an hreflang tag pointing to itself.
    • Broken links: LemRank follows the URLs specified in hreflang attributes to check for any 404 errors or other HTTP status codes indicating broken links.

    LemRank performs these site audits on a weekly cadence, providing regular updates on your hreflang status. This allows you to quickly identify and rectify any new issues that may arise, helping to ensure that search engines always serve the most appropriate version of your content to users worldwide.

    Frequently asked questions

    Do I need hreflang if I only target one country?

    No — hreflang is only for multi-language or multi-region sites. Single-country single-language sites should skip it entirely.

    What is x-default?

    The fallback version shown when no other hreflang matches the user's language. Typically used for the language picker page or the English default.

    Should I use hreflang or ccTLDs for country targeting?

    Both work — ccTLDs (example.de, example.fr) give strong signals but require separate sites. Subdomains or subfolders with hreflang are cheaper to maintain and equally effective when done correctly.

    Was this page helpful?

    Try LemRank free

    14-day Pro trial. No credit card required.

    Start free trial
    Ready to try it?

    Do this in LemRank — track hreflang automatically

    Skip the manual work. LemRank runs the tracking, alerts you on movement, and explains every change with AI.

    14-day free Pro trial · No credit card required · Cancel anytime