How To Add Hreflang Tags In WordPress Without Plugin

Not everyone visiting your website is going to be familiar with English. Supporting multiple languages on your website based on the visitor’s location will not only help in improving the user experience but also give your website a boost in the search engine rankings.

What is a Hreflang tag?

The hreflang tag is an HTML code that helps search engines such as Google display the correct version of a page based on the visitor’s language and region.

Below is the syntax that should be used for helping Google deliver the correct version of the page.

<link rel="alternate" hreflang="lang_code" href="url_of_page" />

Here you can replace the lang_code with en-us for English language and for visitors from the United States. The url_of_page should be replaced with the link to the localized version of the page. The code:

<link rel="alternate" hreflang="en-us" href="" />

Similarly, fr-fr for French language and visitors from France. The code:

<link rel="alternate" hreflang="fr-fr" href="" />

You can also use code such as en-gb to target English speakers in the UK.

<link rel="alternate" hreflang="en-gb" href="" />


While the task of adding hreflang tags on your website can be achieved easily with the help of plugins. It is often not recommended to install plugins for small tasks which can be done by adding just a few lines of code.

Adding hreflang tags to your WordPress website without using a plugin

  1. Navigate to Appearance -> Theme Editor from your admin dashboard.
  2. Open the header.php file.
  3. Under the <head> tag paste the below code:
    <link rel="alternate" hreflang="x-default" href="" />
    <link rel="alternate" hreflang="en-us" href="" />
    <link rel="alternate" hreflang="fr-fr" href="" />
    <link rel="alternate" hreflang="de-de" href="" />

The x-default hreflang is used for visitors who do not match any language or region profile and will be directed to a default page for all.

4. Once done click on the Update File button at the bottom.

Your website will now redirect to the correct version of the page based on the visitor’s language and region.


If you want to show similar content in multiple languages on your website then hreflang tags are a must. There are various benefits to using hreflang tags which will help in growing your website and making it user friendly.

Have questions or confused about something WordPress Related? Join Our Discord Server & ask a Question

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top
Scroll to Top