Hreflang and html lang don't match: which one is wrong?
If a checker tells you your page's <html lang> doesn't match its hreflang, the two attributes are describing the same page in two different languages. They do different jobs, so one of them is lying, and usually it's the one nobody looks at: a template default. Here's how to tell which one is wrong, how much it matters, and how to fix it once for the whole site.
Two attributes, two jobs
They look alike, but they answer different questions.
hreflang lives in <link rel="alternate"> tags in the page's head (or in the HTTP header, or the sitemap). It says: "this page also exists in these languages, at these addresses." Search engines use it to choose which version of a page to show each person. It's about the relationship between URLs.
<html lang> is one attribute on the page's opening tag. It says: "the text on this page is in this language." Browsers read it, and so do screen readers and the browser's own "translate this page?" prompt. A screen reader uses it to choose its pronunciation, so a German page marked lang="en" gets read aloud with English rules.
So a page at /de/preise should carry <html lang="de"> and, in its hreflang list, name itself as the de version. When the checker says they don't match, it means something like this:
<html lang="en">
...
<link rel="alternate" hreflang="de" href="https://example.com/de/preise" /> <!-- this page -->
<link rel="alternate" hreflang="en" href="https://example.com/pricing" />
The hreflang says "I'm the German page". The html tag says "I'm in English".
Does Google care which one is right?
Less than you might fear. Google has said it works out a page's language from its visible text, and doesn't rely on the lang attribute for that. What it does rely on is the hreflang set, to connect the versions and show the right one.
That means a wrong <html lang> on its own is unlikely to sink your rankings. My checker shows it as a warning, not an error, for that reason. Fix it anyway, for three reasons:
- People with screen readers hear your page in the wrong accent, or worse.
- Browsers offer to translate a page that's already in the reader's language, or don't offer when they should.
- It's often a symptom. A mismatch sometimes means the hreflang is the wrong one: the page is listed under the wrong language. That one does affect search.
Find out which side is wrong
You don't need tools for this, only the page in front of you.
- Read the visible text. What language is the page actually in? That's the truth. Both attributes should match it.
- Look at the address. A page under
/de/that hreflang callsdeand the text is German: the html tag is wrong. That's the common case. - Check the page's own entry in the list. Find the hreflang line whose address is this page. If the text is German but this page is listed as
en, the hreflang is wrong, and so is probably every page's list, because they're generated together. - Check a second language. Open the English version too. If it says
<html lang="en">and the German one also saysen, a template is printing one fixed value for every page.
One thing that isn't a mismatch: a region. <html lang="de"> on a page listed as de-AT is fine. Both say German, and the checker on FolioPress compares only the language part for this reason. A difference in country alone won't trigger the warning.
The usual causes
In order of how often I see them:
A hardcoded value in the theme. The base template says <html lang="en"> in plain text, written when the site had one language. Every translation inherits it. This is by far the most common one, and the easiest to fix.
A translation plugin that rewrites the content but not the tag. Some setups translate the body of the page on the way out and leave the head alone. The text and hreflang change; the attribute stays at the original language.
Two settings that hold the "same" thing. The CMS has a site language (used for <html lang>) and the translation layer has its own list of languages (used for hreflang). Someone changes one and not the other.
Swapped entries in the hreflang list. The German address sits next to hreflang="en" and the English one next to de. The html tags are right and the list is wrong. Rare, but it's the case that hurts search, and the checker's other results usually show it too: the pages won't list themselves under the code you expect.
Fix it at the source
Whatever the cause, the cure is the same idea: both values should come from one place, the language of the page being shown.
- A theme or template: replace the fixed
lang="en"with whatever variable your system has for the current page's language. In WordPress themes that's usually a function in the header template; in most other systems it's a variable for the current locale. One edit fixes every page. - A plugin: look for a setting that controls the html lang attribute, and check that the theme isn't printing its own.
- A hand-built site: if you keep a table of pages and languages to write hreflang, write the html tag from the same table.
Then run the hreflang checker again on two pages in different languages. The html lang line should now pass, showing the language you expect. Check the rest of the report while you're there: if a list was swapped, you'll also see problems with self-reference and return links, which the hreflang errors guide covers in the order to fix them.
When you can leave it
If the only difference is a region, for example en against en-GB, there's nothing to fix. If a page genuinely mixes two languages, such as a bilingual legal notice, mark the page with its main language and wrap the other passages in an element with their own lang. Hreflang can't describe that; it's one language per URL.
How FolioPress handles it
In FolioPress, the html lang attribute and the hreflang list come from the same place: the language of the page being shown, taken from your site's list of languages. A German page gets <html lang> set to your German language code and lists itself under the same code, with no separate setting to forget. A page only lists the languages it has a version in. The rest of the multilingual SEO setup (translated addresses, canonicals, x-default, sitemap entries) is built in the same way.
The limit: that's true of the themes that come with FolioPress. If you write your own theme, the base template is yours, and you'll want to use the page's language variable rather than a fixed value. The theming guide shows what every template can see. And none of this fixes a site you run somewhere else. For that, the checker and the steps above are the way to go. If you'd rather stop maintaining it, plans start at €12 a month with a 30-day free trial, and every plan includes every language (pricing).