How to fix html lang on Adobe Commerce (Magento)

Add a correct `lang` attribute to your site's `<html>` tag so browsers, search engines, and assistive technologies know what language your store is written in.

Steps for Adobe Commerce (Magento)

  1. The <html> tag with lang is rendered by the root page template. Locate the file: app/design/frontend/<Vendor>/<Theme>/Magento_Theme/templates/root.phtml (for custom themes) or the equivalent in vendor/magento/module-theme/view/frontend/templates/root.phtml.
  2. Open root.phtml in your custom theme (never edit core files directly) and find the <html tag.
  3. Magento provides a helper to output locale/language info. Add the lang attribute using the store's locale: <html lang="<?= $block->escapeHtmlAttr(strstr($currentLocale, '_', true)) ?>"> — or hard-code the BCP 47 tag if you have a single-language store, e.g., <html lang="en">.
  4. For a cleaner approach, use the Locale Resolver: inject \Magento\Framework\Locale\ResolverInterface in a custom block and output the language code.
  5. After saving, run bin/magento cache:clean and bin/magento setup:static-content:deploy, then verify via View Page Source on the frontend.
Official Adobe Commerce (Magento) documentation ↗
<html lang="en-US">

What is html lang?

Every web page starts with an `<html>` tag. Adding a `lang` attribute to that tag — for example, `<html lang="en">` for English — tells browsers, screen readers, and search engines what human language the page is written in. It is a single line of code that lives at the very top of every page on your site. Without it, software has to guess your language, and it often guesses wrong.

Search engines like Google use the `lang` attribute to serve your pages to users searching in the right language and country, which directly affects how much relevant organic traffic you receive. Screen readers used by visually impaired shoppers rely on it to pronounce words correctly — missing or wrong language declarations are one of the most common WCAG accessibility failures, and in many jurisdictions selling online without meeting basic accessibility standards carries legal risk. Browser features like built-in translation also depend on this attribute, so without it, customers browsing in a different language may get broken or missing translation prompts, reducing conversions. It is one of the easiest fixes on your entire site and leaves no good reason to skip it.

See the complete Html lang guide for every platform and the full background.

Not sure if your Adobe Commerce (Magento) store has this?

Run a free SEOLZ audit — we’ll find html lang and every other issue across your whole site.

Scan my site free

Fix html lang on another platform