The hreflang tag acts as a signpost for search engines, especially Google, so they understand that your site is localised for several languages. It helps make sure visitors searching in different languages find the most relevant version of your site.
There are two ways to tag pages:
- Content in different languages, for example en, de or fr.
- Content in regional variants of the same language, for example en-US or en-GB.
For example, if you create a Spanish version of your English homepage, you tag it as “Spanish”, which adds hreflang=”es”. The Spanish version of your page is then shown to visitors with an IP address in a Spanish-speaking country.
Hreflang can also specify variants of the same language. For pages aimed at Spanish speakers in Mexico, the hreflang tag is set to “es-MX”, where “es” stands for Spanish and “MX” represents Mexico. Google has a guide with best practices for hreflang tags.
Note: when you add a new language and create a multilingual site, the language code updates automatically for every page created in the new language. If you only need a few individual pages in another language – without making the whole site multilingual – you can change the code manually.
Adding a language code
The language code sets the lang attribute on the page’s <html> tag.
- Click Pages in the top bar to open the Page Manager and find the page you want to make language-specific.
- Click the Page settings icon to open the page’s settings.
- On the General tab, go to the Language Code section and choose the language from the dropdown.
- Click Submit and publish your site for the change to take effect.
The language code (hreflang tag) you chose appears in the page’s <head> section.