The hreflang attribute is an HTML attribute specified on hyperlink elements such as <a> and <area> to indicate the language of the linked resource, using a valid BCP 47 languagetag (e.g., "en" for English or "fr-CA" for Canadian French).[1] It serves as an advisory hint for user agents and search engines to better understand the internationalization of content, though it does not override the actual language determined from the resource itself, such as via HTTP headers or content analysis.[1] This attribute enables web developers to provide contextual information about alternate representations of documents, facilitating improved user experiences in multilingual environments.[2]In standard hyperlink usage, hreflang specifies the language of a target document referenced by an <a> element, helping browsers and assistive technologies prioritize or process links appropriately.[3] For example, <a href="https://example.com/fr" hreflang="fr">Version française</a> signals that the linked page is in French.[1] However, its most prominent application today is in the <head> section of HTML documents via <link rel="alternate" hreflang="lang"> elements, where it denotes alternate versions of the current page tailored to specific languages or geographic regions.[4] This bidirectional linking—where each variant page references all others—prevents search engines from treating translated content as duplicates and ensures users receive region-specific results, such as "en-GB" for British English versus "en-US" for American English.[5]Hreflang plays a critical role in international search engine optimization (SEO), particularly for global websites, by guiding engines like Google to serve the optimal localized version to users based on their browser settings, search query, or location.[5] Implementation can occur in three primary ways: inline in HTML<link> tags, HTTP response headers (e.g., Link: <https://example.com/en>; rel="alternate"; hreflang="en"), or XML sitemaps, with a recommended "x-default" value for non-matching languages or regions to act as a fallback.[5] Common pitfalls include invalid BCP 47 tags, missing self-references, or unidirectional links, which can lead to indexing errors or suboptimal rankings; validation tools and consistent use across all variants are essential for effectiveness.[5]Defined initially in the HTML 4.01 specification as a means to describe link target languages, hreflang has evolved within the living HTML standard maintained by the WHATWG, remaining purely advisory while integrating with modern web internationalization practices.[3][1] Its adoption surged with the rise of multilingual web content in the 2010s, supported by major search providers, and it continues to be universally compatible across browsers since at least 2015.[2]
Introduction
Definition and Purpose
The hreflang attribute is an HTML mechanism used within <link> and <a> elements to indicate the language and optional geographic targeting of a linked resource, such as alternate versions of a webpage tailored for different languages or regions.[6] This attribute provides a way for web developers to annotate hyperlinks, signaling to user agents and search engines the intended audience for the linked content based on linguistic and locational preferences.[6]Its primary purpose is to assist search engines, particularly Google, in identifying and serving the most appropriate variant of a multilingual or multi-regional webpage to users, thereby aligning results with the viewer's language settings or geographic location.[5] By clarifying relationships between equivalent pages, hreflang helps mitigate duplicate content penalties in internationalsearch engine optimization (SEO), where similar content across languages might otherwise be misinterpreted as redundant.[5][7] It is invariably used in conjunction with the rel="alternate" relation type to denote that the linked page represents an alternative representation of the same core content.[7][5]Key benefits include enhancing user experience through the delivery of localized content that matches individual preferences, thereby increasing relevance and engagement.[5] Additionally, it supports improved visibility in international search rankings by consolidating ranking signals across related pages and explicitly defining content interconnections for sites operating in multiple languages or regions.[7]Google first recommended the hreflang attribute in December 2011 as a targeted solution for optimizing multilingual websites.[7]
Historical Development
Prior to the introduction of the hreflang attribute in 2011, website owners managing internationalcontent encountered substantial difficulties in communicating language and regional variations to search engines, often resulting in duplicate content penalties. Without clear signals, search engines like Google treated similar pages across languages or regions as duplicates, potentially suppressing rankings; site operators typically depended on strategies such as using country-code top-level domains (ccTLDs) like .fr for Frenchcontent, subdomains (e.g., fr.example.com), or geotargeting settings in webmaster tools to mitigate these issues.Google officially recommended the hreflang attribute on December 13, 2011, as an extension to the existing rel="alternate" link type, enabling webmasters to specify alternate versions of a page for different languages or regions directly in HTML, HTTP headers, or XML sitemaps. This innovation, detailed in Google's Webmaster Central Blog post titled "New markup for multilingual content," addressed the growing need for better handling of multilingual websites by allowing bidirectional annotations that inform crawlers of equivalent content clusters, thereby improving user experience and search relevance without risking penalties.[8]The hreflang attribute, originally part of HTML specifications for indicating link languages since HTML 4.01, was further formalized in the HTML5 recommendation published by the W3C on October 28, 2014, which included support for its use in the element alongside rel="alternate." It is compatible across major browsers.Key milestones in hreflang's evolution include Google's April 2013 announcement of the "x-default" value, which allows specification of a fallback or non-language-targeted page (e.g., the main homepage) for users whose preferences do not match any explicit variant, supported initially by Google and Yandex, and later by other engines like Bing.[9][5] Subsequent refinements appear in Google's Search Central documentation.[5]Hreflang has seen widespread adoption among international websites, integrated natively or via plugins in content management systems like WordPress (e.g., through Yoast SEO and WPML), and routinely validated using Google Search Console's International Targeting report.
Technical Specifications
Syntax and Values
The hreflang attribute specifies the language and optional regional targeting of an alternate resource using a language tag as its value. The basic syntax follows the format hreflang="language-region", where the language subtag is a two-letter code from ISO 639-1 (e.g., "en" for English), optionally followed by a hyphen and a two-letter region subtag from ISO 3166-1 alpha-2 (e.g., "US" for United States), resulting in values like "en-US". An optional script subtag from ISO 15924 (e.g., "Latn" for Latin script) may also be included, as in "zh-Latn".[5][10]Values for the hreflang attribute must conform to the IETF BCP 47 standard for language tags, which defines a structured format of up to three primary subtags (language-script-region) separated by hyphens, though in practice for hreflang, implementations typically limit to language and region subtags. BCP 47 ensures interoperability by standardizing tags for use in protocols like HTTP and HTML attributes.[10]The attribute is case-insensitive, meaning "en-US" and "EN-us" are treated equivalently by parsers and search engines, though the conventional casing uses lowercase for the language subtag and uppercase for the region subtag.[11]The hreflang attribute must be paired with rel="alternate" to indicate an alternate version of the page and a valid href attribute providing the URL of the linked resource; without these, the annotation is invalid and ignored.[5][10]Invalid values, such as three-letter language codes (e.g., "eng" instead of "en"), non-standard region codes, or reserved subtags like "EU" or "UN", result in the hreflangannotation being ignored by search engines and user agents.[12][5]
Language and Region Codes
Hreflang attributes utilize standardized language tags to specify the intended audience for alternate versions of a webpage, drawing from established international codes for precision and interoperability. The primary language subtag is based on ISO 639-1, which provides two-letter codes for the world's major languages, such as "en" for English, "fr" for French, and "zh" for Chinese.[13][5] For hreflang implementations, only these two-letter ISO 639-1 codes are supported by search engines; three-letter ISO 639-2 codes are not used.[5][14]Region subtags follow ISO 3166-1 alpha-2, consisting of two uppercase letters appended after a hyphen to denote geographic targeting rather than linguistic differences alone, for example, "FR" for France or "CA" for Canada.[15][5] This allows hreflang to distinguish content variants intended for specific locales, such as regional dialects or localized preferences, without altering the core language identifier.Script subtags, governed by ISO 15924 and part of the BCP 47 framework, are optional four-letter codes that address variations in writing systems for languages with multiple scripts, such as "Hans" for Simplified Chinese or "Latn" for Latin script in English ("en-Latn").[14][5] They prove particularly valuable for languages like Arabic ("ar-Arab") or Japanese ("ja-Jpan"), enabling precise matching for users preferring specific orthographies.[14]When combining subtags, hreflang tags follow BCP 47 syntax with hyphens separating elements, prioritizing necessity to avoid redundancy—for instance, "es-MX" targets Mexican Spanish, contrasting with "es-ES" for European Spanish, while omitting script subtags unless ambiguity arises, such as in "zh-Hans" for Simplified Chinese versus "zh-Hant" for Traditional.[14][5] Over-specification, like adding a script to unambiguous cases, is discouraged to maintain simplicity and reduce parsing errors.These codes are registered and maintained in the IANA Language Subtag Registry, which ensures consistency across web protocols, while Google's guidelines stress using exact, valid tags to prevent misinterpretation by search engines and deliver relevant content to users.[14][5]
The x-default value in hreflang annotations, introduced by Google in 2013, serves as a non-standard attribute to designate a fallback or default page for users whose preferred language and region do not match any explicitly annotated variants.[16] This allows search engines to direct such users to a neutral resource, such as a generic homepage or language selector, rather than an irrelevant localized version; for instance, an English-language default page might be shown to users from unspecified regions without dedicated content.[5] Unlike standard language codes, x-default is not derived from BCP 47 and signals a page that targets no specific locale, enhancing user experience on multilingual sites.[17]Usage of x-default follows specific rules to ensure consistency within hreflang clusters. It must point to a single default URL per set of related pages, and annotations are required to be bidirectional, meaning every page in the set—including the default—must reference all others, including the x-default itself.[5] This reciprocity prevents fragmented signaling to crawlers. Although x-default is a Google-specific extension, it is widely adopted in hreflang implementations and processed by supporting engines like Yandex, while non-supporting ones such as Bing ignore it without affecting standard tags.[18]Other special cases in hreflang configurations include handling right-to-left (RTL) scripts, such as Arabic or Hebrew, where no dedicated attribute is needed beyond the appropriate language code (e.g., hreflang="ar"); instead, sites must implement CSS for proper bidirectional text rendering to avoid layout issues. Additionally, the use of "und" for undetermined language is non-recommended and effectively deprecated in favor of x-default, as it lacks the precision for fallback signaling and may confuse crawlers.[19]Limitations of x-default emphasize its neutral role: it should never point to a page in a specific language or region, as this would undermine its purpose as a catch-all.[5] Google's documentation, updated as of 2023, underscores its importance for global sites lacking full localization, where it facilitates serving appropriate content to unmatched user preferences without over-specifying targets.[17]Engine support for x-default has been robust since its 2013 launch, allowing validation through tools like the now-deprecated International Targeting report in Search Console, which flagged inconsistencies until its removal in 2022.[20] Current validation relies on URL Inspection and third-party crawlers, confirming widespread adherence in production environments.[5]
Implementation Methods
In HTML Documents
The primary method for implementing hreflang annotations in HTML documents involves using the <link> element with rel="alternate" in the <head> section of the page. This tag specifies alternate versions of the content for different languages or regions, using the syntax <link rel="alternate" hreflang="lang_code" href="url_of_page" />, where lang_code follows the language-region format defined in relevant specifications.[5] Self-referential tags are supported and recommended, allowing a page to link to itself with its own language code, such as <link rel="alternate" hreflang="en" href="https://example.com/en/" />.[5]All hreflang annotations must be placed within the <head> section to ensure they are parsed by search engine crawlers before the body content loads. A key requirement is bidirectionality: every page in a set of language or regional variants must include <link> tags pointing to all other pages in the set, including itself, to form a complete and reciprocal network. This ensures search engines can accurately map relationships across the variants without ambiguity.[5]For example, consider a website offering content in English for the US and UK, as well as French. Each page would include the following tags in its <head>:
This setup signals to search engines that these URLs represent equivalent content tailored to specific audiences.[5]This HTML-based approach offers advantages for static websites, where tags can be manually added to templates, making it straightforward to implement without server-side configuration. It is immediately visible to web crawlers upon page fetch, enabling quick recognition of international variants and reducing risks of duplicate content penalties.[5]Hreflang via HTML <link> tags is supported in HTML5 and later standards, with practical compatibility in HTML4 and XHTML through tolerance of non-standard attributes by parsers and crawlers. No JavaScript is required for basic implementation, though dynamic generation is common in content management systems.
Via HTTP Headers
Hreflang annotations can be implemented using the HTTP Link header in server responses, which is particularly useful for non-HTML resources where embedding tags in a document head is not possible.[5] This method allows search engines like Google to identify alternate language or regional versions of a resource by including multiple Link headers or comma-separated entries within a single header.[5]The standard format for the Link header follows the syntax specified in RFC 8288, using the rel="alternate" relation type combined with the hreflang attribute. For instance, a response might include:
This indicates that the English (en) and French (fr) versions of file.pdf are alternate representations of the same content.[5] Multiple variants can be listed in one header separated by commas, or separate Link headers can be used for each.[5]This approach is ideal for file types such as PDFs, images, or API endpoints that lack an HTML structure.[5] For example, when serving a French PDF at https://example.com/fr/document.pdf, the server can include Link headers pointing to English and other language equivalents, enabling search engines to serve the appropriate version to users based on their language preferences.[5] Server-side configuration is required, such as using the Header directive in Apache's .htaccess file (e.g., Header always add Link "<https://example.com/en/>; rel=\"alternate\"; hreflang=\"en\"" for specific paths) or the add_header directive in Nginx server blocks (e.g., add_header Link '<https://example.com/en/>; rel="alternate"; hreflang="en"';).All URLs in the Link header must be absolute, starting with a protocol like https://, to ensure unambiguous resolution by crawlers.[5] Additionally, the annotations must be bidirectional: each variant's response should include links to all other variants, including a self-referential link with its own hreflang value.[5]Google's crawler has respected Link headers for hreflang since 2011, aligning with the attribute's initial rollout for international targeting. By 2025, major content delivery networks like Cloudflare fully support transmitting and modifying these headers, often via edge-side includes or Workers scripts, facilitating scalable implementation across distributed infrastructures.[21]
In XML Sitemaps
Incorporating hreflang annotations into XML sitemaps allows website owners to signal alternate language and regional versions of content in bulk to search engines like Google, facilitating better international targeting without modifying individual pages. This method extends the standard XML sitemap protocol by embedding <xhtml:link> elements within each <url> entry, using the XHTML namespace (xmlns:xhtml="http://www.w3.org/1999/xhtml"). Each <url> must include a <loc> tag for the page's canonical URL, followed by <xhtml:link> tags for all alternate versions, including a self-referential link with the appropriate hreflang value. This ensures bidirectional referencing across the content cluster, where every variant points to all others, helping search engines group related pages accurately.[5]For a complete example, consider a sitemap file (sitemap.xml) structured as follows for a content cluster with English and German versions. Note that to represent a full cluster efficiently, the same set of <xhtml:link> elements appears under each <url> entry, though this results in some redundancy; for very large sites, separate sitemaps per language cluster can be used via a sitemap index file.
This format adheres to the XML sitemap extension for international targeting, initially introduced by Google in 2012 to support multilingual and multinational annotations using rel-alternate-hreflang elements.[22][5]To submit the sitemap, upload the XML file to a publicly accessible directory on the website and notify search engines through Google Search Console's Sitemaps report, the Search Console API, or by referencing it in the site's robots.txt file (e.g., Sitemap: [https](/page/HTTPS)://example.com/sitemap.xml). Each sitemap file is limited to 50,000 URLs or 50 MB uncompressed, making it suitable for sites with extensive international content by allowing multiple sitemaps linked via a sitemap index.[23]The primary advantages of this approach include efficiency for large-scale sites, as it centralizes hreflang signals in a single file rather than distributing them across pages, reducing maintenance overhead. Search engines crawl sitemaps less frequently than individual pages, yet this method provides comprehensive, static signals that remain effective for guiding content serving to users based on language and region preferences, as outlined in Google's current guidelines.[5][23]
Best Practices and Troubleshooting
Recommended Practices
To maximize SEO benefits and user experience in multilingual websites, implement hreflang attributes following established guidelines that ensure search engines like Google can accurately serve the appropriate language or regional variant to users. This involves creating a robust network of interlinked pages that signal content relationships clearly, avoiding misinterpretation that could lead to duplicate content penalties or suboptimal rankings.[5]A core strategy is to establish bidirectional and self-referential links across all pages in a hreflang variant set, where each page references every other variant—including itself—to form a complete graph that confirms the pages as equivalents. This mutual linking prevents search engines from treating variants as isolated or duplicate content, thereby enhancing crawl efficiency and international targeting. For instance, if a site has English (en) and Spanish (es) versions of a product page, the en page must include hreflang tags pointing to both itself and the es page, and vice versa.[24][25]Always use absolute URLs in hreflang attributes to eliminate ambiguity from relative paths, specifying the full domain and protocol (e.g., https://www.example.com/en-gb/about) to ensure consistent resolution across different server environments and crawlers. Relative URLs can cause parsing errors or incorrect variant matching, particularly on subdomains or when redirects are involved, so absolute formats are essential for reliability.[26][27]Incorporate the x-default attribute for every hreflang set as a fallback mechanism, directing users without a specific language or region match to the site's primary or most generic version, such as the global English page. This tag, denoted as hreflang="x-default", helps manage untagged traffic and improves usability for international audiences where no explicit variant applies, aligning with Google's recommendation to cover all potential user scenarios.[5][24]Regular audits are vital for maintaining hreflang integrity, including verifying canonical tag alignment where identical content across variants shares the same canonical URL to prevent indexing conflicts. Tools like Screaming Frog SEO Spider facilitate this by crawling sites to detect broken links, missing reciprocals, or syntax errors in hreflang implementations, allowing for proactive fixes. Consistent checks, ideally quarterly, ensure ongoing compliance and performance.[28][29]As of 2025, integrating hreflang with AI translation tools like CAMB.AI enables dynamic generation of localized content variants while automatically embedding proper tags for SEO readiness, streamlining multilingual scaling for global sites. Additionally, prioritize mobile-first indexing signals by confirming that hreflang attributes render correctly on mobile pages, as Google continues to favor mobile-optimized experiences in international search results.[30][26]
Common Mistakes and Solutions
One prevalent error in hreflang implementation is the omission of self-referential tags, where a page fails to include a hreflang annotation pointing to its own URL. This incompleteness disrupts the set of language variants, potentially causing search engines to ignore the entire group of annotations or misinterpret the page's targeting. To resolve this, every page variant must include a self-referential tag, such as <link rel="alternate" hreflang="en" href="https://example.com/en/" />, ensuring the current page's URL is listed among the alternates.[5]Another frequent issue involves incorrect or mismatched language and region codes, such as using "en-uk" instead of the standard "en-GB" for British English. Invalid codes, which must adhere to ISO 639-1 for languages and ISO 3166-1 Alpha 2 for regions, lead to annotations being disregarded by search engines, resulting in improper geographic or linguistic targeting and reduced visibility for international users. Validation against the IANA Language Subtag Registry and using crawling tools like Screaming Frog or hreflang validation services can identify and correct these discrepancies.[5]Unidirectional links occur when one page references an alternate version but the alternate does not reciprocate, breaking the bidirectional requirement for hreflang sets. This asymmetry can cause search engines to overlook the connections, treating pages as unrelated duplicates and potentially triggering penalties for duplicate content. Ensuring symmetry through automation in content management systems (CMS), such as WordPress plugins or custom scripts, guarantees that all variants mutually link to each other.[5]For global sites, neglecting the x-default attribute leaves no fallback for users whose language or region is not explicitly targeted, leading to suboptimal user experiences and erratic search result serving. As per Google guidelines, implement x-default on all variants to direct unmatched queries to a neutral page, such as a homepage or selector, and verify functionality using Google Search Console's Performance report to monitor international query performance or third-party diagnostics.[5][17]Additional problems include blocking search engine crawlers from alternate pages via robots.txt or applying noindex tags to variants, which prevents proper indexing and can result in ignored hreflang signals or duplicate content penalties. Mixing hreflang with conflicting directives like noindex further exacerbates these issues by signaling unavailability. Site owners should review crawl accessibility in Google Search Console's Coverage report and use third-party tools to diagnose and remediate such blocks.[5]
12.1. The hreflang attribute provides user agents with information about the language of a resource at the end of a link, just as the lang attribute provides ...
Use hreflang to tell Google about the variations of your content, so that we can understand that these pages are localized variations of the same content.
Nov 4, 2025 · The hreflang attribute on a elements that create hyperlinks, if present, gives the language of the linked resource. It is purely advisory. The ...
We've expanded our support of the rel="alternate" hreflang link element to handle content that is translated or provided for multiple geographic regions.
The hreflang attribute on the link element has the same semantics as the hreflang attribute on the a element. The type attribute gives the MIME type of the ...
Below is a merged summary of the language tag structure for `hreflang` use, combining all the information from the provided segments into a single, comprehensive response. To maximize density and clarity, I’ll use a table in CSV format for key details (structure, examples, and guidelines) and supplement it with additional text for broader context and useful URLs. This ensures all information is retained while being concise and well-organized.
The country codes can be represented either as a two-letter code (alpha-2) which is recommended as the general-purpose code, a three-letter code (alpha-3) which ...Glossary for ISO 3166 · Country Codes Collection · ISO 3166-1:2020 · ISO/TC 46
The new x-default hreflang attribute value signals to our algorithms that this page doesn't target any specific language or locale and is the default page when ...
May 8, 2023 · The hreflang x-default value is used to specify the language and region neutral URL for a piece of content when the site doesn't support the user's language ...
Nov 27, 2024 · Make sure to have bidirectional hreflang attribute references. Correctly define language and region combinations. Always set hreflang="x-default ...
Mar 1, 2022 · This guide discusses what hreflang is, what it is for and gives in-depth information on how to implement it for your multilingual websites.Table Of Contents · 3. An Xml Sitemap Hreflang... · Other Technical Aspects Of...
In December 2011 we announced annotations for sites that target users in many languages and, optionally, countries. These annotations define a cluster of ...<|control11|><|separator|>
Google supports several sitemap formats. Follow this guide to learn about formats, how to build a sitemap, and how to submit a sitemap to Google.Missing: hreflang | Show results with:hreflang
Mar 7, 2025 · Hreflang is HTML code that you can add to your website to tell various search engines which language and region a web page is meant for.What Is Hreflang And How To... · Tools For Hreflang... · Hreflang Best Practices
Jun 2, 2025 · In this guide, we'll discuss some best practices for hreflang SEO and how to avoid the common pitfalls when implementing hreflang tags on your website.Missing: documentation | Show results with:documentation
Google recommends using different URLs for each language version of a page rather than using cookies or browser settings to adjust the content language on the ...
Jun 29, 2025 · Master hreflang tags for international SEO. This guide covers implementation, common mistakes, and best practices to target the right ...Hreflang Tags: A... · Common Hreflang Mistakes And... · Tools For Hreflang...
This tutorial walks you through how you can use the Screaming Frog SEO Spider tool to check hreflang implementation quickly and efficiently.5) View The Hreflang Tab · 7) Click 'hreflang' & View... · 8) View The Lower Window...<|control11|><|separator|>
Mar 31, 2025 · Hreflang tags and canonical tags are indicators for Google and other search engines for which web pages to index and show to certain searchers.