Webflow sync, pageviews & more.
NEW

How can I append the "lang" attribute of the HTML tag on a specific page in Webflow for my multilingual website?

TL;DR
  • Determine each page's language and corresponding code (e.g., "en", "es", "fr").
  • In Webflow Page Settings, add a custom script like to the "Inside " or "Before " section for each language-specific page.

To set the lang attribute on the <html> tag for a specific page in your multilingual Webflow site, you need to use a small script since Webflow doesn’t allow direct editing of the <html> tag per page.

1. Decide the Target Language per Page

  • Identify the language of the page (e.g., English, Spanish, French).
  • You’ll use the page language code (e.g., en, es, fr) in your script.

2. Add Custom Page Code in Page Settings

  • Go to Pages panel in your Webflow Designer.

  • Hover over the specific page and click the gear icon to open Page Settings.

  • Scroll down to the "Before tag" or "Inside " section.

  • Paste the following inline script, updating "en" with your desired language code:

    <script>document.documentElement.lang = "en";</script>

3. Repeat for Each Language Page

  • For Spanish: <script>document.documentElement.lang = "es";</script>
  • For French: <script>document.documentElement.lang = "fr";</script>
  • Add the script only on the corresponding language version of the page.

Summary

Add a small inline script via Page Settings to change the lang attribute on the <html> tag per page. This ensures accessibility and SEO optimization for multilingual sites.

Rate this answer

Other Webflow Questions