There are two ways to add hreflang tags in WordPress:
Manually
This involves editing your website’s header.php file and adding the hreflang tags to the <head> section. The syntax for hreflang tags is as follows:
<link rel="alternate" hreflang="[language code]" href="[URL of the page in the specified language]">
For example, if you have a page in English and a page in Spanish, the hreflang tags would look like this:
<link rel="alternate" hreflang="en" href="https://bertan.net/my-page-in-english">
<link rel="alternate" hreflang="es" href="https://bertan.net/my-page-in-spanish">
Using a plugin
There are a number of plugins available that can automatically add hreflang tags to your WordPress website. Some popular plugins include:
-
- Hreflang Manager
- MultilingualPress
- Yoast SEO
These plugins make it easy to add hreflang tags to your website without having to edit your code.
Which method you choose to add hreflang tags to your WordPress website will depend on your specific needs and preferences. If you are comfortable editing code, then manually adding the hreflang tags is a good option. If you prefer to use a plugin, then there are a number of good options available.