Hreflang is an HTML attribute that specifies the connection and determination targeting of a webpage. You usage it connected planetary oregon multilingual websites to awesome to hunt engines—notably Google—the connection oregon determination saltation of your content.
With hreflang decently implemented connected your website, idiosyncratic making an online hunt from Germany is much apt to spot the German mentation of your tract successful their hunt results.
While idiosyncratic successful the United States would astir apt spot the English version.
How Hreflang Works
The hreflang property is added to a webpage’s nexus constituent (<link>) successful the <head> conception oregon HTTP header.
To instrumentality hreflang, you should see a abstracted nexus constituent for each connection oregon determination mentation of your page. And see a notation to the existent page.
Hreflang attributes travel a circumstantial structure:
Let’s interruption that down.
- link rel=”alternate”: Signals that determination are aggregate versions of the page
- href= “https://www.yourwebsite.de”: Specifies the implicit URL for the alternate version
- hreflang=”de-DE”: Indicates the hreflang property specifying the contented is for German speakers successful Germany
Here’s an illustration of hreflang tags utilized by HubSpot connected their website:
As you tin see, HubSpot includes 7 hreflang attributes—a hreflang cluster—in its website code.
Each property corresponds to 1 of the superior markets it serves. Plus an further x-default hreflang property for users whose preferences bash not lucifer immoderate of the specified languages oregon regions.
How to Properly Implement Hreflang successful HTML
To efficaciously instrumentality hreflang attributes and assistance hunt engines place the close mentation of your site, travel these steps:
- Identify which languages and countries your website is targeting
- Decide wherever to enactment your hreflang attributes
- Set up your hreflang tags the close way
Step 1: Identify Target Languages and Regions
Your hreflang attributes request to lucifer the connection and determination versions disposable connected your website.
You mightiness person a abbreviated database similar Slack, which targets a fewer cardinal markets:
Or a agelong 1 similar IKEA, which targets implicit 112 countries and languages.
So, earlier everything else, beryllium wide connected which languages and regions you’re targeting.
This task is easier if your tract already provides contented successful aggregate languages—you’ll person the indispensable data.
But if you’re successful the archetypal stages of processing your international SEO strategy, you’ll request to behaviour elaborate marketplace investigation and assemblage research.
Whichever signifier you’re at, don’t skip this step.
Step 2: Decide Where to Put Hreflang Attributes
You person 3 options for adding hreflang attributes:
- In the HTML caput section
- Within the website sitemap
- Through HTTP headers
Let’s look astatine each of these much closely.
HTML Head Section
Directly embedding hreflangs successful each page’s HTML <head> conception is reasonably straightforward.
But, it mightiness beryllium tricky for larger websites to support hreflang attributes accordant and close passim hundreds of pages.
Jeep’s website incorporates hreflang successful the <head> conception to negociate connection and determination targeting of their galore website variations.
Website Sitemap
Alternatively, you tin adhd hreflang annotations successful your sitemap.
It’s an businesslike mode to grip hreflang, particularly for sites with extended contented crossed aggregate languages.
This method centralizes management, simplifies updates, and declutters the HTML caput section—potentially speeding up page load times.
HTTP Header
For non-HTML files, similar PDFs, you tin usage the HTTP header to specify hreflang attributes.
This method involves tweaking web server configurations and mightiness beryllium a spot complex. But it’s bully signifier to marque definite your non-HTML contented reaches the close audience.
Here’s a array showing the pros and cons of each method and erstwhile to usage it.
HTML <head> section | Direct and easy accessible by hunt engines.Straightforward to instrumentality connected static pages. | Can beryllium challenging to negociate for ample sites with galore pages.Requires updating each page, which tin beryllium precise cumbersome and prone to errors. | Small to Medium WebsitesBest for sites with a manageable fig of pages for casual attraction and updates. |
Website Sitemap | Centralizes hreflang accusation successful 1 place.Ideal for ample sites with galore pages.
Easier to update and maintain. |
Requires hunt engines to crawl the sitemap to observe hreflang attributes.May not beryllium instantly disposable to hunt engines connected idiosyncratic leafage crawls. | Large WebsitesSuitable for sites with extended numbers of pages oregon predominant contented updates. |
HTTP Header | Necessary for non-HTML contented (e.g., PDFs, images).Ensures non-text contented is correctly targeted astatine the intended connection and region. | More method to instrumentality arsenic it requires entree to your web server.Not suitable for each types of content. | Non-HTML ContentIdeal for delivering determination oregon language-specific non-HTML content. |
Step 3: Set Up Hreflang Tags Correctly
You tin adhd hreflang attributes successful immoderate order.
You tin spot them earlier the nexus destination:
<link rel=”alternate” hreflang=”en” href=”http://yourwebsite.com/en” />Or after:
<link rel=”alternate” href=”http://yourwebsite.com/en” hreflang=”en” />It doesn’t matter. Search engines volition recognize it either way.
Here’s what’s precise important, though:
Make definite the connection and state codes—defined by ISO standards—are accurate.
- Language codes are based connected the ISO 639-1 format. They’re two-letter codes that correspond the connection of the content. For example, “en” for English, “es” for Spanish, and “fr” for French.
- Country codes are defined by the ISO 3166-1 alpha-2 standard. These are two-letter codes of the people state oregon region. Examples see “US” for the United States, “CA” for Canada, and “MX” for Mexico.
Combining Language and Country Codes
You could specify lone the connection erstwhile utilizing a hreflang attribute. Like this:
<link rel=”alternate” hreflang=”es” href=”http://yourwebsite.com/es” />This targets Spanish speakers globally—which is imaginable but mostly not recommended owed to little precise targeting.
For much close targeting, we urge combining some connection and state codes.
For example:
<link rel=”alternate” hreflang=”es-ES” href=”http://yourwebsite.com/es-es” />This property specifically targets Spanish speakers successful Spain.
Similarly, for French-speaking users successful Canada, you would use:
<link rel=”alternate” hreflang=”fr-CA” href=”http://yourwebsite.com/fr-ca” />Hreflang Examples
Let’s look astatine real-world examples of hreflang attributes successful practice.
HTML Section Implementation
Take a look astatine 1 of ASOS’ class pages.
Start with their UK site.
Then, comparison it to their Spanish site.
You’ll announcement the hreflang clusters connected some sites are identical.
And each 1 references each different version, including itself.
But here’s the absorbing part.
When you browse their website, you’ll announcement you tin prime from a wide scope of countries to store from, not conscionable the ones listed successful the hreflang cluster.
So, what gives?
Enter “x-default”.
The ”x-default” worth provides a fallback URL for visitors whose determination oregon connection does not lucifer immoderate specified successful the hreflang cluster.
Therefore, for a shopper from Singapore, a portion not explicitly covered by the hreflang cluster, the “x-default” mounting ensures they entree a wide mentation of the site.
Website Sitemap Implementation
Below is an illustration of hreflang attributes successful a website sitemap.
This is for a website targeting US shoppers, arsenic good arsenic English and French speakers successful Canada.
<?xml version=”1.0” encoding=”UTF-8”?> <urlset xmlns=”http://www.sitemaps.org/schemas/sitemap/0.9” xmlns:xhtml=”http://www.w3.org/1999/xhtml”> <url> <loc>http://www.yourwebsite.com/english-page-ca/</loc> <xhtml:link rel=”alternate” hreflang=”en-CA” href=”http://www.yourwebsite.com/english-page-ca/” /> <xhtml:link rel=”alternate” hreflang=”fr-CA” href=”http://www.yourwebsite.com/french-page-ca/” /> <xhtml:link rel=”alternate” hreflang=”en-US” href=”http://www.yourwebsite.com/english-page-us/” /> </url> <url> lt;loc>http://www.yourwebsite.com/french-page-ca/</loc> <xhtml:link rel=”alternate” hreflang=”en-CA” href=”http://www.yourwebsite.com/english-page-ca/” /> <xhtml:link rel=”alternate” hreflang=”fr-CA” href=”http://www.yourwebsite.com/french-page-ca/” /> <xhtml:link rel=”alternate” hreflang=”en-US” href=”http://www.yourwebsite.com/english-page-us/” /> </url> <url> <loc>http://www.yourwebsite.com/english-page-us/</loc> <xhtml:link rel=”alternate” hreflang=”en-CA” href=”http://www.yourwebsite.com/english-page-ca/” /> <xhtml:link rel=”alternate” hreflang=”fr-CA” href=”http://www.yourwebsite.com/french-page-ca/” /> <xhtml:link rel=”alternate” hreflang=”en-US” href=”http://www.yourwebsite.com/english-page-us/” /> </url> </urlset>Let’s interruption that down:
- The sitemap follows the modular operation specified by the sitemap protocol
- You’ll spot that it specifies each mentation of the leafage for English and French speakers successful Canada, arsenic good arsenic for English speakers successful the US
- This configuration is repeated for each targeted version
HTTP Header Implementation for Non-HTML Content
For non-HTML content, specified arsenic multimedia files oregon PDFs, you’ll request to configure the web server to adhd HTTP headers.
This process varies based connected your web server—whether it’s Apache, Nginx, IIS, oregon other. You request to adhd configuration rules to see the close nexus headers for each portion of content.
For example, if your contented is disposable successful English (US), German, and Spanish (Spain), here’s however you’d format the HTTP headers:
<https://subdomain.yoursite.com/en-us/example.pdf>; rel="alternate"; hreflang="en-us", <https://subdomain.yoursite.com/de/example.pdf>; rel="alternate"; hreflang="de", <https://subdomain.yoursite.com/es/example.pdf>; rel="alternate"; hreflang="es"Tools for Hreflang Implementation
Here are a fewer tools that tin marque it easier to instrumentality hreflang connected your website:
CMS Plugins
Many contented absorption systems (CMS) person plugins designed for hreflang management.
For WordPress users, cheque retired the “Hreflang Manager” plugin. Shopify store owners tin usage a similar tool tailored to their platform.
Dedicated Hreflang Tools
Beyond CMS-specific options, determination are respective tools that tin assistance you with due hreflang implementation and monitoring.
These include:
Hreflang Best Practices
Hreflang attributes can’t warrant that hunt engines volition ever amusement your preferred tract version.
But they’re a beardown awesome that helps hunt engines place the astir applicable mentation for users based connected their determination and language.
Here are immoderate champion practices to travel for optimal results.
Include Bidirectional Links
Every mentation of your website should see links to each different connection oregon determination versions. As good arsenic a nexus backmost to itself.
This creates a two-way transportation among each versions.
For example, if a circumstantial leafage connected your tract has versions successful English (US) and German, some pages should see identical hreflang tags similar this:
<link rel="alternate" hreflang="en-US" href="https://www.yoursite.com/en-us/apple-watch" /> <link rel="alternate" hreflang="de" href="https://www.yoursite.com/de/apple-watch" />Use Absolute URLs
Always usage afloat URLs similar “https://backlinko.com/google-analytics-4” to debar immoderate disorder for hunt engines. Avoid comparative URLs specified arsenic “/product/apple-watch.”
Apply Hreflang Attributes connected All Relevant Pages
Don’t bounds hreflang attributes to the homepage oregon a fewer prime pages. Implement them crossed each leafage that has a connection oregon determination alternative.
Include the “x-default” Hreflang Attribute
Use the “x-default” worth for users with languages not specifically targeted by hreflang tags truthful you nonstop them to a wide mentation of your site.
Regularly Monitor Your Hreflang Attributes
You tin usage a instrumentality similar Semrush’s Site Audit to find and hole communal hreflang errors.
Here’s how:
Start by entering your website URL. Then, click connected “Start Audit.”
Make definite the “Crawl Scope,” “Limit of checked pages.” and “Crawl source” are acceptable accurately. Then, click connected “Start Site Audit.”
The instrumentality volition past statesman to crawl and audit your site. When the audit is complete, you’ll beryllium presented with a elaborate study outlining each the discovered issues.
Click connected the “Issues” tab.
Use the hunt barroom to benignant successful “hreflang.” This volition filter the database to lone amusement hreflang-related issues.
As you tin see, Backlinko doesn’t person immoderate hreflang issues.
But if you find an contented connected your site, you tin click connected each 1 for a elaborate report.
This volition instrumentality you to a database of URLs containing that circumstantial issue. You tin besides click connected the “Why and however to hole it” nexus adjacent to each contented for much accusation connected however to code the issue.
Common Hreflang Mistakes to Avoid
Even with cautious planning, it’s communal to tally into issues erstwhile utilizing hreflang tags.
Here are immoderate predominant mistakes:
- Omitting self-referential hreflang attributes
- Using incorrect connection oregon state codes
- Forgetting to see reciprocal (return) hreflang tags
- Failing to usage canonical tags and hreflang tags together
- Pointing alternate versions of a leafage to the aforesaid URL
Omitting Self-Referential Hreflang Attributes
Every leafage indispensable see a self-referencing hreflang tag to bespeak its targeted connection and region.
For example, let’s accidental you person a webpage connected reddish sneakers with 3 antithetic versions: English (US), English (UK), and French (France).
Each of these pages should person a hreflang tag that points to itself, alongside tags for the different versions.
This means the US English mentation of the leafage should see each 3 hreflang tags:
<link rel="alternate" hreflang="en-US" href="https://www.yourwebsite.com/en-us/red-sneakers" /> <link rel="alternate" hreflang="en-GB" href="https://www.yourwebsite.com/en-gb/red-sneakers" /> <link rel="alternate" hreflang="fr-FR" href="https://www.yourwebsite.com/fr/red-sneakers" />And ne'er omit the self-referencing hreflang tag, similar so:
<link rel="alternate" hreflang="en-GB" href="https://www.yourwebsite.com/en-gb/red-sneakers" /> <link rel="alternate" hreflang="fr-FR" href="https://www.yourwebsite.com/fr/red-sneakers" />Using Incorrect Language oregon Country Codes
Language and state codes tin beryllium tricky due to the fact that they’re not ever intuitive.
For example, the close codification for the United Kingdom is “GB” (not “UK”). And for targeting Hong Kong, you usage “zh-HK” alternatively of “zh-CN,” which is for mainland China.
To debar mistakes, ever double-check these codes for accuracy. Refer to the authoritative lists of language and country codes to marque definite you’re doing it right.
Forgetting to Include Reciprocal Links
A communal mistake with hreflang attributes is not referencing each different versions—including itself— connected the HTML page.
For example, if your website has versions successful Spanish for Mexico, English for the US, and English for Canada, you mightiness incorrectly miss the Canadian version, similar so:
<link rel="alternate" hreflang="en-US" href="https://www.yourwebsite.com/en-us/" /> <link rel="alternate" hreflang="es-MX" href="https://www.yourwebsite.com/es-mx/" />The close attack is to guarantee each mentation is referenced connected each pages:
<link rel="alternate" hreflang="en-US" href="https://www.yourwebsite.com/en-us/" /> <link rel="alternate" hreflang="es-MX" href="https://www.yourwebsite.com/es-mx/" /> <link rel="alternate" hreflang="en-CA" href="https://www.yourwebsite.com/en-ca/" />Failing to Use Canonical Tags and Hreflang Tags Together
Both canonical and hreflang tags should beryllium contiguous connected your HTML leafage erstwhile you person antithetic versions of a page.
The hreflang tags archer hunt engines the connection and determination targeting of a page. The canonical tag specifies the superior version.
For example, if you person 2 versions of a page—a leafage successful English for the United States and different successful Spanish for Mexico—each leafage should see a canonical tag pointing to its respective URL.
So don’t conscionable bash this:
<link rel="alternate" hreflang="en-US" href="https://www.yourwebsite.com/en-us/" /> <link rel="alternate" hreflang="es-MX" href="https://www.yourwebsite.com/es-mx/" />Add the canonical nexus element, too.
For the US version:
<link rel="alternate" hreflang="en-US" href="https://www.yourwebsite.com/en-us/" /> <link rel="alternate" hreflang="es-MX" href="https://www.yourwebsite.com/es-mx/" /> <link rel="canonical" href="https://www.yourwebsite.com/en-us/" />For the Mexico version:
<link rel="alternate" hreflang="en-US" href="https://www.yourwebsite.com/en-us/" /> <link rel="alternate" hreflang="es-MX" href="https://www.yourwebsite.com/es-mx/" /> <link rel="canonical" href="https://www.yourwebsite.com/es-mx/" />Pointing Alternative Versions of a Page to the Same URL
Each mentation of a leafage should person its ain unsocial URL.
This means that erstwhile you’re adding hreflang attributes, each hreflang nexus constituent indispensable beryllium a antithetic URL.
Don’t mistakenly constituent antithetic versions to the aforesaid URL:
<link rel="alternate" hreflang="en-CA" href="https://www.yourwebsite.com/page" /> <link rel="alternate" hreflang="en-AU" href="https://www.yourwebsite.com/page" />Instead, each mentation should constituent to its circumstantial URL:
<link rel="alternate" hreflang="en-CA" href="https://www.yourwebsite.com/en-ca/" /> <link rel="alternate" hreflang="en-AU" href="https://www.yourwebsite.com/en-au/" />Boost Your Site’s International Reach Beyond Hreflang
You’re disconnected to a large commencement present that you’ve got the bent of utilizing hreflang attributes.
But are each the different signals for planetary SEO moving successful your favor?
It’s clip to find retired with this in-depth usher to planetary SEO.
The station What Is Hreflang and How To Implement It the Right Way appeared archetypal connected Backlinko.