Learning Hub — Beginner's Guide
⭐ Beginner — No coding experience needed

What you will learn in this guide

1 What are hreflang tags?

Let us start from the very beginning. You do not need to know anything about international SEO to understand this — we will build it up step by step.

What problem do hreflang tags solve?

Imagine you have a website in two languages — English and French. You have an English version of your homepage at yourdomain.com/en/ and a French version at yourdomain.com/fr/. The content on both pages is essentially the same — just in different languages.

Without hreflang tags, Google sees two pages with very similar content and gets confused. It might decide they are duplicates and only show one of them. Worse, it might show the English version to French users or the French version to English users. Neither of these outcomes is what you want.

Hreflang tags solve this by telling Google explicitly: "These pages are not duplicates — they are the same content in different languages. Show the English one to English speakers and the French one to French speakers."

Do I need hreflang tags?

You need hreflang tags if any of the following apply to your website:

If your website is in one language only and you only serve one country, you do not need hreflang tags at all. You can skip this tutorial.

What does a hreflang tag look like?

A hreflang tag is a link tag that goes inside the <head> section of your HTML file. Here is an example for a page that exists in English and French:

<!-- On the English page --> <link rel="alternate" hreflang="en" href="https://yourdomain.com/en/page" /> <link rel="alternate" hreflang="fr" href="https://yourdomain.com/fr/page" /> <link rel="alternate" hreflang="x-default" href="https://yourdomain.com/en/page" />

The same set of tags — pointing to both versions — must appear on the French page too. Every language version must reference all the others.

2 Understanding language and region codes

Before you write any hreflang tags you need to know the correct codes for your languages and regions. Using the wrong code means Google silently ignores your tags.

Language codes

Language codes are two-letter codes based on the ISO 639-1 standard. They are always written in lowercase. Here are the most common ones:

LanguageCode
Englishen
Frenchfr
Germande
Spanishes
Italianit
Portuguesept
Dutchnl
Japaneseja
Chinese (Simplified)zh

Region codes

If you need to target a specific country — not just a language — you add a region code after the language code, separated by a hyphen. Region codes are two-letter country codes written in uppercase.

Target audienceHreflang code
English speakers in the UKen-GB
English speakers in the USen-US
English speakers in Australiaen-AU
French speakers in Francefr-FR
French speakers in Canadafr-CA
Spanish speakers in Spaines-ES
Spanish speakers in Mexicoes-MX
Portuguese speakers in Brazilpt-BR

What is x-default?

x-default is a special hreflang value that tells Google which page to show when none of the other language versions match. For example, if someone visits from a country you do not have a specific version for, Google will show the x-default page. This is usually your main English or international version.

💡 Not sure which code to use? If you only need to separate by language (not country), use just the language code — en, fr, de. Only add the region code if you have different content for the same language in different countries — like a UK English site and a US English site with different prices.

3 Check if your hreflang tags are missing or incorrect

  1. 1 Go to the AIPageSEO audit tool Open a new browser tab and go to https://aipageseo.com/seo-audit-platform.html.
  2. 2 Enter your page address and run the audit Type the address of one of your multilingual pages and click Run Audit.
  3. 3 Find the Hreflang section Scroll to the Hreflang section. The audit will show you which hreflang issues were found. Common flags include: HREFLANG_MISSING (no tags at all), HREFLANG_XDEFAULT (missing x-default tag), HREFLANG_RETURN (other language versions do not link back), HREFLANG_CODE (invalid language code used).
  4. 4 Also check by viewing page source Right-click your page and choose View Page Source. Press Ctrl + F and search for hreflang. If you get zero results, your page has no hreflang tags at all. If you find some, read through them to check all language versions are listed and the codes look correct.

4 Plan your hreflang tags before opening any files

Before you open Notepad++ or FileZilla, write out the complete set of hreflang tags you need. This makes the process much faster and reduces mistakes.

The rules you must follow

  1. 1 Every page must reference itself Each page must include a hreflang tag pointing to its own URL. The English page must include a tag for the English version. The French page must include a tag for the French version.
  2. 2 Every page must reference all other language versions If you have English, French and German versions, every one of those three pages must include all three hreflang tags — pointing to English, French and German URLs. If the German page is missing a hreflang tag pointing to the French version, Google may ignore the whole set.
  3. 3 Always include an x-default tag Every page in the set must include an x-default tag pointing to the fallback version — usually your main English or international page.
  4. 4 Always use absolute URLs The href values in hreflang tags must be full absolute URLs starting with https://. A relative URL like /fr/page will not work.

Template — fill in your own values

Here is what a complete set of hreflang tags looks like for a site with English and French versions:

<!-- Add this to EVERY language version of the page --> <link rel="alternate" hreflang="en" href="https://yourdomain.com/en/page" /> <link rel="alternate" hreflang="fr" href="https://yourdomain.com/fr/page" /> <link rel="alternate" hreflang="x-default" href="https://yourdomain.com/en/page" />

Write this out for your own URLs before moving to the next section. You will copy and paste it into each of your files.

5 Add hreflang tags to your HTML files using Notepad++

Now you add the tags to each language version of the page. You need to do this for every language version — not just one.

  1. 1 Open FileZilla and connect to your server Fill in Host, Username and Password, leave Port blank, click Quickconnect.
  2. 2 Navigate to your website folder Double-click httpdocs (Plesk) or public_html (cPanel) in the right panel.
  3. 3 Download the English version of the page Find the English language version of the page you want to add hreflang tags to. Right-click it and choose Download. Rename the downloaded file to pagename-backup.html. Download it again to your Desktop as your working copy.
  4. 4 Open the file in Notepad++ Open Notepad++ → File → Open → navigate to your Desktop → click the file → click Open.
  5. 5 Find the canonical tag Press Ctrl + F and search for canonical. Click at the end of that line and press Enter to create a new blank line. This is where you will paste your hreflang tags.
  6. 6 Paste your hreflang tags Type or paste the full set of hreflang tags you planned in Section 4. Add a comment above them to keep your code organised:
    <link rel="canonical" href="https://yourdomain.com/en/page" /> <!-- Hreflang --> <link rel="alternate" hreflang="en" href="https://yourdomain.com/en/page" /> <link rel="alternate" hreflang="fr" href="https://yourdomain.com/fr/page" /> <link rel="alternate" hreflang="x-default" href="https://yourdomain.com/en/page" />
  7. 7 Save the file Press Ctrl + S.
  8. 8 Repeat for every other language version Download the French version of the same page from FileZilla. Open it in Notepad++. Add the exact same set of hreflang tags — the full set pointing to all language versions. Save it. Repeat this for every language version of the page. Every version must have the complete set of tags.

6 Upload all updated files back to your server

  1. 1 Switch back to FileZilla Click FileZilla in your taskbar. Reconnect if needed.
  2. 2 Upload each updated file Find each updated file on your Desktop in the left panel. Right-click each one and choose Upload. Click Overwrite when prompted. Make sure you upload every language version — not just one.
  3. 3 Verify in View Page Source Open a browser tab and go to each language version of the page. Right-click and choose View Page Source. Press Ctrl + F and search for hreflang. You should see all your hreflang tags listed correctly in the head section of each page.
  4. 4 Request indexing for each page in Google Search Console Log in to Google Search Console. Use the URL Inspection tool to request indexing for each language version of the page. This tells Google to re-crawl the pages and read the new hreflang tags.
✅ Tutorial complete — your hreflang tags are added and Google has been notified.

7 Common mistakes to avoid

  1. Only adding hreflang tags to one language version This is the most common mistake. Every language version of the page must have the complete set of hreflang tags. If the French page does not have hreflang tags pointing back to the English page, Google may ignore the entire hreflang implementation.
  2. Using relative URLs instead of absolute URLs The href value in every hreflang tag must start with https:// and include your full domain name. Writing /fr/page instead of https://yourdomain.com/fr/page will not work.
  3. Using an invalid language or region code Language codes must be lowercase two-letter ISO codes — en, fr, de. Region codes must be uppercase — GB, US, FR. The separator between language and region must be a hyphen — en-GB not en_GB. Google silently ignores invalid codes.
  4. Forgetting the x-default tag Every page in a hreflang group must include an x-default tag. Without it Google does not know which page to show to users whose language does not match any of your versions.
  5. Pointing hreflang tags to pages that return 404 Every URL in your hreflang tags must be a live, working page that returns a 200 status. If a URL in your hreflang tags returns 404, Google will ignore the whole set. Always check that every URL you reference actually works before uploading.
Written by
John
Founder, AIPageSEO

Hreflang tags are one of the most misunderstood parts of international SEO. Get them wrong and Google shows the English version of your page to French users, or the French version to English users. I wrote this guide because the fix is simpler than most people think once you understand what is actually going on.