html_lang_override
6 sites
No security coverage
The HTML Lang Override module allows site administrators to explicitly define the lang attribute of the tag on a per-page basis or globally across the site.
- This is particularly useful for websites that:
- Do not use Drupal's multilingual system.
- Contain only a few pages in languages other than the default.
- Require precise control over the HTML lang attribute for SEO or accessibility compliance.
By default, Drupal sets the HTML lang attribute based on the site’s configured language. However, when a specific page is written in a different language and this is not reflected in the HTML lang tag, it can lead to SEO issues—especially when using hreflang meta tags. This module addresses that by letting you override the language code globally or on individual pages.
Features
- Set a global default for the HTML lang attribute across all pages.
- Override the HTML lang attribute for individual nodes (via the node edit form).
- Define per-page language settings by path, including views and custom routes.
- Helps resolve SEO warnings related to mismatched language codes in hreflang URLs and the HTML document.
Post-Installation
After installing the module:
- A configuration form is available under admin configuration for setting a global language code and per-path language overrides.
- A new field is added to the “Advanced” section of the node edit form, allowing editors to specify a language code for that specific node.
- The default global language is initialized based on the site’s current default language.
Additional Requirements
No additional modules are required. This project works with Drupal Core only.