Skip to content
Nazmul Nikhil
Menu

Hreflang Defined but HTML Lang Missing (Ahrefs): Add the Lang Attribute

Ahrefs flags pages that have hreflang tags but no html lang attribute. Here's why both are worth having and how to add lang on each platform.

Nazmul Nikhil

By

Head of SEO & Assistant Manager, Digital Marketing at Notionhive

Published 1 min read
Hreflang Defined but HTML Lang Missing (Ahrefs): Add the Lang Attribute
Photo: iStrfry, Marcus on Unsplash

In short

Ahrefs flags "Hreflang defined but HTML lang missing" when a page has hreflang annotations but no lang attribute on its <html> tag. Search engines use hreflang, so rankings aren't directly affected. But screen readers, browser translation and other tools rely on lang, and on a multilingual site getting it wrong means pages are read aloud in the wrong accent. Add a lang attribute that matches each page's own hreflang value.

The site has done the harder part, hreflang, but skipped the simple one.

The fix

On the German page with hreflang="de" for itself:

<html lang="de">

Where to set it

WordPress: make sure the theme's header.php uses <html <?php language_attributes(); ?>>. Multilingual plugins then set the right language per page.

Shopify: theme.liquid should open with <html lang="{{ request.locale.iso_code }}">.

Webflow and Wix: both set lang automatically with their localization features. If it's missing, check custom code that replaces the page head.

Custom builds: set lang from the page's locale in the root layout. In single-page apps, set it in the server-rendered HTML, not only with JavaScript after load.

This guide isn't affiliated with or endorsed by Ahrefs.

Sources and references

TAGSAhrefs Site AuditHreflang defined html lang missingHtml lang missing multilingualAdd lang attribute
Nazmul Nikhil

About the author

Nazmul Nikhil

Head of SEO & Assistant Manager, Digital Marketing at Notionhive

SEO and AI search consultant in Dhaka, Bangladesh, helping small and mid-size businesses in the USA, UK, Australia and Canada.

Need help with this?

Get it fixed with International SEO

I find the issues that cost you traffic and fix them, starting with the pages that matter most.

Keep reading

Related articles

All Site Audit Issues posts →

Get the next guide in your inbox

One email when a new SEO or AI search guide goes live.

Ready to grow?

Get a free audit of your website, or book a 30-minute call to talk through your goals.

Nazmul Hasan

Talk to Nazmul directly

Reply within 24h

WhatsApp +880 1682835118
nazmulnikhil@gmail.com