How to Fix URLs with Mismatched hreflang and HTML lang Declarations

How to Fix URLs with Mismatched hreflang and HTML lang Declarations

Free Complete Site Audit

Access a full website audit with over 300 technical insights.

Something went wrong. Please, try again later.
Trusted by
Sitechecker trusted company

Free Website SEO Checker & Audit Tool

  • Scan the site for 300+ technical issues
  • Monitor your site health 24/7
  • Track website rankings in any geo

The URL has hreflang annotations and HTML lang attributes that do not match.

The Importance of the Issue

While Google and Yandex use hreflang to determine which URLs to display in regional search results, some search engines, such as Bing, use the HTML lang attribute.

If a URL uses both hreflang and HTML lang, yet the values do not match, this implies that an error has been made with either the hreflang annotation, or with HTML lang, or both.

This may result in the incorrect page being served in localised search results.

How to Check the Issue

In our Site Audit tool, under the “Localization” category, you’ll find a crucial component aimed at optimizing your website’s global SEO strategy. One of the specific issues highlighted is “Mismatched hreflang and HTML lang Declarations.” This indicates pages where there’s a discrepancy between the language declared in the HTML lang attribute and the hreflang attribute used for language and regional URL targeting.

Mismatched hreflang and HTML lang Declarations

By clicking on ‘View issue,’ you can access a detailed list of pages where this mismatch occurs. Our tool not only identifies the problem but also guides you through the rectification process, ensuring your site adheres to best practices for international SEO.

Enhance International Visibility with Our Hreflang Checker!

Perfect your website’s global strategy by correcting hreflang and HTML lang inconsistencies.

Something went wrong. Please, try again later.

How to Fix This Issue

Fixing the mismatch between language-targeting tags and web page markup lang attributes involves ensuring that both attributes consistently specify the same language and region codes on your web pages. Here’s a step-by-step guide to address this issue:

1. Understand the Difference

  • html lang attribute: Specifies the language of the content in the HTML document.
  • hreflang attribute: Specifies the language and optionally the region of the linked resource, indicating to search engines the language and region of the target URL.

2. Identify the Mismatch

Check your webpage’s source code to identify where the mismatch occurs. Typically, it will look like this:



...
<link rel="alternate" href="https://example.com/fr/" hreflang="fr">
<link rel="alternate" href="https://example.com/de/" hreflang="de">
...

3. Match the lang and hreflang tags

Ensure that the lang attribute in your <html> tag corresponds to the appropriate language-targeting attribute values used in your alternate links.

If your website has different versions for English, French, and German, you need to set the HTML lang attribute for each version to match the markup language values in the alternate links:

For the English version:


<html lang="en">
<head>
<link rel="alternate" href="https://example.com/fr/" hreflang="fr">
<link rel="alternate" href="https://example.com/de/" hreflang="de>
<!-- other head elements -->
</head>
<body>
<!-- content -->
</body>
</html>

For the French version:


<html lang="fr">
<head>
<link rel="alternate" href="https://example.com/en/" hreflang="en">
<link rel="alternate" href="https://example.com/de/" hreflang="de>
<!-- other head elements -->
</head>
<body>
<!-- content -->
</body>
</html>

For the German version:


<html lang="de">
<head>
<link rel="alternate" href="https://example.com/en/" hreflang="en">
<link rel="alternate" href="https://example.com/fr/" hreflang="fr>
<!-- other head elements -->
</head>
<body>
<!-- content -->
</body>
</html>

4. Validate Your Changes

  • Manual Check. Manually inspect the web page markup source code of your pages to ensure the lang and language-targeting attributes match as required.
  • Tools and Validators. Use tools such as Google’s Search Console, and Sitechecker to verify that the hreflang and html lang attributes are correctly implemented and matched.

5. Common Mistakes to Avoid

  1. Incorrect Language Codes. Ensure that you are using the correct ISO 639-1 language codes (e.g., en for English, fr for French).
  2. Incorrect Region Codes. If specifying regions, ensure they follow the correct format (e.g., en-US for American English, en-GB for British English).
  3. Omitting Alternate Links. Ensure every language/region version of your site includes alternate links for all other versions.

By following these steps, you can ensure that the lang attribute and hreflang attributes are correctly matched, improving your site’s SEO and usability for different language audiences.

Final Idea

To fix hreflang and web page markup lang mismatches, ensure both attributes consistently specify the same language and region codes. Identify mismatches by checking your webpage’s source code, then match the html lang attribute with the hreflang values in the alternate links for each language version. Validate your changes using tools like Google’s Search Console. Avoid mistakes like using incorrect language or region codes and omitting alternate links. This ensures improved SEO and usability for different language audiences.

FAQ
The hreflang attribute specifies the language and optionally the region of the linked resource, indicating to search engines the language and region of the target URL.
Check your webpage's source code to identify mismatches. Ensure the lang attribute in the <html> tag corresponds to the hreflang values in your alternate links.
Matching these attributes improves your site's SEO and usability for different language audiences by ensuring search engines correctly understand the language and regional targeting of your pages.
Manually inspect your HTML source code and use tools like Google's Search Console and Sitechecker to verify that the markup language and html lang attributes are correctly implemented and matched.
Fast Links

You may also like

View More Posts
No Reciprocal Hreflang (no Return Tag) Issue
Site Audit Issues
No Reciprocal Hreflang (no Return Tag) Issue
Ivan Palii
Mar 25, 2024
How to Fix URLs with Duplicate Page Descriptions
Site Audit Issues
How to Fix URLs with Duplicate Page Descriptions
Ivan Palii
Jun 20, 2023
How to Fix Invalid URL Characters
Site Audit Issues
How to Fix Invalid URL Characters
Ivan Palii
Mar 13, 2024
close