Table Of Contents
Introduction
If your WordPress website serves visitors from different countries or speaks to audiences in multiple languages, you have probably wondered how to make sure the right people see the right version of your content. This is exactly where hreflang tags come in.
Hreflang tags are a simple but powerful piece of HTML code that you place on your web pages to tell search engines – primarily Google – which language and region each page is targeting. Without them, Google may show your Spanish-language page to French users, or display your US-focused content to visitors in Australia. That creates a poor experience for your audience and can seriously hurt your search rankings.
The good news is that adding hreflang tags in WordPress is not as complicated as it sounds. Whether you are using a multilingual plugin, managing things manually, or running a multisite network, this guide walks you through everything – step by step, in plain language.
By the end of this article, you will know exactly what hreflang tags are, why they matter for your international SEO strategy, and how to implement them correctly on your WordPress site.
What Are Hreflang Tags?
Hreflang tags are HTML attributes that communicate language and regional targeting information to search engines. The name itself gives you a clue: “href” refers to a hyperlink reference, and “lang” stands for language.
Google introduced the hreflang attribute in 2011 specifically to help websites that offer content in multiple languages or for multiple regions. When a search engine crawls your website and finds hreflang tags, it understands the relationship between your different language versions and can serve the most relevant one to each user.
A typical hreflang tag looks like this:
<link rel=”alternate” hreflang=”es” href=”https://www.example.com/es/” />
In this example, the tag tells Google that the page at that URL is the Spanish-language version of the content. The hreflang value “es” is the ISO 639-1 language code for Spanish.
Language Codes vs. Region Codes
You can use hreflang tags in two ways. First, you can target a language alone – for example, “fr” for French speakers everywhere. Second, you can combine a language with a region – for example, “fr-CA” for French speakers specifically in Canada, or “fr-FR” for French speakers in France.
Here is a quick comparison:
| Hreflang Value | What It Means | Example Use Case |
|---|---|---|
| en | English (all regions) | Blog for all English speakers worldwide |
| en-US | English for the United States | US-specific product pricing page |
| en-GB | English for the United Kingdom | UK-specific spelling and content |
| es | Spanish (all regions) | Spanish content for all Spanish speakers |
| es-MX | Spanish for Mexico | Mexican Spanish product descriptions |
| pt-BR | Portuguese for Brazil | Brazilian Portuguese landing page |
| zh-Hans | Simplified Chinese | Content for mainland China audience |
| x-default | Default fallback page | Homepage for unmatched regions |
Why Hreflang Tags Matter for Multilingual SEO
Search engines are smart, but they are not perfect. When you have multiple pages of similar content in different languages, Google can easily get confused. It might treat your translated pages as duplicate content, which can actually hurt your rankings. Or it might show the wrong version to the wrong audience, driving away visitors who cannot read the language they see.
Hreflang tags solve both of these problems. They tell Google that your pages are intentional translations or regional variations – not duplicates – and guide the search engine to serve the most appropriate version to each visitor.
Key Benefits of Using Hreflang Tags
- Better User Experience: Visitors see content in their own language and for their own region. This immediately increases engagement and reduces bounce rates.
- Avoiding Duplicate Content Penalties: Google understands that your French and English pages cover the same topic intentionally. Without hreflang, it might penalise one or both pages.
- Improved Search Rankings in Target Markets: When Google serves the correct local version, that page can rank more competitively in the appropriate country’s search results.
- Higher Conversion Rates: Users who find content in their native language and local context are significantly more likely to take action – whether that is making a purchase, signing up, or contacting you.
- Stronger International Presence: A properly configured multilingual site with hreflang tags signals to Google that you are a credible, well-structured resource for an international audience.
How Hreflang Tags Work: The Technical Basics
Before diving into the WordPress setup, it helps to understand how hreflang tags function at a technical level. Do not worry – we will keep it simple.
Where Do Hreflang Tags Go?
Hreflang tags can be placed in three different locations:
- In the HTML <head> section – This is the most common method. Each page includes <link rel=”alternate” hreflang=”…”> tags inside its <head>.
- In the HTTP headers – For non-HTML files like PDFs, you can add hreflang information via HTTP response headers. This is rarely used for standard web pages.
- In the XML sitemap – You can declare hreflang relationships inside your XML sitemap using a specific format. This works well for larger sites.
For most WordPress sites, the HTML <head> method is recommended. Plugins typically handle this automatically, but it is good to understand what is happening behind the scenes.
The Self-Referencing Rule
One of the most important (and often missed) rules of hreflang implementation is that every page must reference all other language versions AND itself. This is called self-referencing.
For example, if you have an English page and a Spanish page, your English page must include:
<link rel=”alternate” hreflang=”en” href=”https://example.com/en/” />
<link rel=”alternate” hreflang=”es” href=”https://example.com/es/” />
And your Spanish page must include both of those exact same tags too. This bidirectional confirmation is how Google verifies that the hreflang relationship is genuine.
The x-default Tag
The special hreflang value “x-default” tells Google which page to show when no other language version matches the user’s preferences. It is typically set to your main homepage or a language selection page. Always include an x-default tag in your hreflang implementation.
<link rel=”alternate” hreflang=”x-default” href=”https://example.com/” />
Common WordPress Multilingual Structures
Before setting up hreflang tags, you need to understand how your WordPress site is structured for multiple languages. The structure you choose affects how URLs are formatted and how your hreflang tags should be written.
Subdirectories (Subdirectories in the Same Domain)
This is the most popular structure and is recommended by Google. Each language version lives in a subfolder of the main domain:
- https://example.com/ (default / English)
- https://example.com/es/ (Spanish)
- https://example.com/fr/ (French)
- https://example.com/de/ (German)
This approach keeps all your site authority on one domain, makes it easy to manage, and is the default output of most WordPress multilingual plugins.
Subdomains
Some websites separate languages into subdomains:
- https://example.com/ (default / English)
- https://es.example.com/ (Spanish)
- https://fr.example.com/ (French)
Subdomains are treated somewhat independently by Google, which means you may need to do more work to build authority for each one. This works well for large organisations with separate teams managing different regions.
Country Code Top-Level Domains (ccTLDs)
Some companies use entirely separate domains per country:
- https://example.com (global / English)
- https://example.es (Spanish)
- https://example.fr (French)
- https://example.de (German)
ccTLDs are the strongest signal for geographic targeting, but they are expensive to maintain and harder to build authority across. Most small to medium WordPress sites stick with subdirectories.
Method 1: Using WPML (WordPress Multilingual Plugin)
WPML is one of the most widely used multilingual plugins for WordPress. It is a premium plugin with a strong reputation for reliability, compatibility with popular themes and plugins, and built-in hreflang support.
Step 1: Install and Activate WPML
- Purchase WPML from wpml.org and download the plugin files.
- In your WordPress dashboard, go to Plugins > Add New > Upload Plugin.
- Upload the WPML ZIP file and click Install Now, then Activate.
- You will be prompted to enter your WPML site key. Enter the key from your WPML account to activate the plugin.
Step 2: Run the WPML Setup Wizard
After activation, WPML launches a setup wizard. Follow these steps:
- Choose your site’s default language – the language your site is currently written in.
- Select the additional languages you want to add. You can add more languages later.
- Choose your URL structure. Subdirectory is recommended (e.g., /es/ for Spanish).
- Configure which content types you want to translate (pages, posts, custom post types, etc.).
- Complete the wizard and click Finish.
Step 3: Configure Hreflang in WPML
WPML automatically generates hreflang tags for your translated pages. Here is where to verify and configure the settings:
- Go to WPML > Languages in your WordPress dashboard.
- Scroll to the “Language URL format” section and confirm your URL structure is correct.
- In the “SEO” section, make sure “Add hreflang tags” is enabled.
- Save your settings.
WPML will now add hreflang tags automatically to every translated page. You do not need to manually write any code. When you create a Spanish translation of your English page, WPML links them together and outputs the correct hreflang tags in the HTML.
Step 4: Translate Your Content
- Open any page or post in the WordPress editor.
- In the Languages section (usually in the right sidebar), click the + icon next to the language you want to translate into.
- This opens the translation editor. Write or paste your translated content.
- When done, click Save & Close or Update.
- WPML automatically creates the hreflang relationship between the original and the translation.
Method 2: Using Polylang (Free Option)
Polylang is a popular free multilingual plugin for WordPress. It may not have every enterprise feature of WPML, but it is perfectly capable for most websites and handles hreflang tags well.
Step 1: Install Polylang
- In your WordPress dashboard, go to Plugins > Add New.
- Search for “Polylang” and click Install Now, then Activate.
Step 2: Configure Languages
- Go to Languages > Languages in your WordPress dashboard.
- Under “Add a new language,” select your default language and any additional languages from the dropdown menus.
- Click Add Language for each one.
- Go to Languages > Settings to configure your URL format (subdirectory is recommended).
Step 3: Hreflang with Polylang
Polylang automatically generates hreflang tags once languages are configured and pages are linked. To link translations:
- Open a page or post in the editor.
- In the Languages panel (sidebar), select the language this content is written in.
- Click the “+” next to another language to create a translation, or link to an existing translated page using the pencil icon.
- Save the page. Polylang will now output hreflang tags for both linked pages.
Polylang’s hreflang output is clean and accurate. If you want to verify it, visit any page on your site, right-click, and choose View Page Source. Search for “hreflang” to confirm the tags are present.
Method 3: Using Rank Math or Yoast SEO
If you already use Rank Math or Yoast SEO for your WordPress site, you may be able to manage hreflang tags through these plugins – particularly when combined with a multilingual plugin.
Rank Math and Hreflang
Rank Math has a built-in multilingual module that integrates with WPML and Polylang. When either of these is active, Rank Math enhances the hreflang output by handling technical SEO aspects like canonical tags alongside hreflang declarations.
To check and enable this:
- Go to Rank Math > Dashboard and enable the “Multilingual SEO” module.
- Make sure WPML or Polylang is also installed and configured.
- Rank Math will automatically coordinate hreflang output with your multilingual plugin.
Yoast SEO and Hreflang
Yoast SEO does not natively generate hreflang tags on its own. However, it works seamlessly with WPML and Polylang, which handle the hreflang output. The Yoast Premium version also has specific compatibility enhancements for WPML.
The general recommendation is: use WPML or Polylang for multilingual management, and let your SEO plugin (Rank Math or Yoast) handle other on-page optimisation like titles, meta descriptions, and sitemaps.
Method 4: Adding Hreflang Tags Manually
If you prefer full control, or if you are running a small site with only a few pages, you can add hreflang tags manually. This requires a little coding, but it is not difficult.
Option A: Using a Child Theme’s functions.php
Never edit your parent theme’s files directly. Instead, use a child theme. To add hreflang tags via functions.php:
Open your child theme’s functions.php file and add this code:
function add_hreflang_tags() {
echo ‘<link rel=”alternate” hreflang=”en” href=”https://example.com/en/” />’ . “\n”;
echo ‘<link rel=”alternate” hreflang=”es” href=”https://example.com/es/” />’ . “\n”;
echo ‘<link rel=”alternate” hreflang=”x-default” href=”https://example.com/” />’ . “\n”;
}
add_action(‘wp_head’, ‘add_hreflang_tags’);
This code hooks into the wp_head action and outputs your hreflang tags inside the <head> section of every page. You would need to customise the URLs and language codes to match your actual site.
For a more dynamic approach – where different pages output different hreflang values – you would use WordPress conditional tags like is_page(), is_single(), or is_home() inside the function to control which tags appear on which pages.
Option B: Using a Plugin Like WPCode
If editing PHP files makes you nervous, WPCode (formerly Code Snippets) is a free WordPress plugin that lets you add custom code without touching theme files. You can paste your hreflang PHP snippet into WPCode and specify it to run only in the header area.
- Install and activate WPCode from the WordPress plugin repository.
- Go to Code Snippets > Add Snippet.
- Give your snippet a name, paste your hreflang PHP code, and set the location to “Site Wide Header.”
- Activate the snippet and save.
Method 5: Adding Hreflang via Your XML Sitemap
For larger WordPress websites, managing hreflang tags inside individual page HTML can get complicated. An alternative is to declare all hreflang relationships inside your XML sitemap. Google reads your sitemap and understands the language relationships without needing the tags on each individual page.
How It Works in the Sitemap
In the sitemap, each page entry includes xhtml:link tags for every language version. Here is what it looks like:
<url>
<loc>https://example.com/en/about/</loc>
<xhtml:link rel=”alternate” hreflang=”en” href=”https://example.com/en/about/”/>
<xhtml:link rel=”alternate” hreflang=”es” href=”https://example.com/es/about/”/>
</url>
Both WPML and Polylang can generate multilingual sitemaps automatically when integrated with Rank Math or Yoast SEO. Once configured, these plugins handle all the sitemap hreflang formatting for you.
Verifying Your Hreflang Tags Are Working
After setting up hreflang tags, you should always verify they are implemented correctly. Errors in hreflang can confuse Google and potentially cause the wrong pages to appear in search results.
Method 1: View Page Source
The simplest check is to view the HTML source of your page:
- Open your website in a browser and navigate to any page.
- Right-click anywhere and choose “View Page Source.”
- Use Ctrl+F (or Cmd+F on Mac) and search for “hreflang.”
- You should see link tags for each language version, including a self-reference and x-default.
Method 2: Google Search Console
Google Search Console is your most reliable source of truth. After submitting your sitemap and waiting for Google to crawl your site, check the International Targeting report under the Legacy Tools section. It will show detected hreflang tags and highlight any errors or warnings.
Method 3: Hreflang Checker Tools
Several free online tools are designed specifically to validate hreflang implementation:
- Ahrefs Hreflang Checker: Scans your page and shows all detected hreflang tags with validation status.
- Semrush Site Audit: Crawls your entire site and reports hreflang errors in a structured report.
- hreflangchecker.com: A free tool dedicated to hreflang validation.
- Screaming Frog SEO Spider: Desktop tool that crawls your site and maps all hreflang relationships for deep auditing.
Common Hreflang Mistakes to Avoid
Even experienced developers sometimes get hreflang implementation wrong. Here are the most common mistakes and how to avoid them:
- Missing the Self-Reference: Every page must include a hreflang tag pointing to itself. Skipping the self-reference is one of the most frequent errors and causes Google to ignore or distrust the entire hreflang set.
- Non-Bidirectional Tags: If page A references page B, then page B must also reference page A. If only one side declares the relationship, Google treats the tags as invalid.
- Incorrect Language Codes: Using made-up or misspelled codes like “eng” instead of “en,” or “sp” instead of “es,” will cause your tags to be ignored. Always use valid ISO 639-1 language codes and ISO 3166-1 alpha-2 region codes.
- Forgetting x-default: Without x-default, Google does not know which page to show users whose language or region does not match any of your specific hreflang values.
- Pointing Hreflang at Redirected URLs: Your hreflang tags must point to the final destination URLs, not to pages that redirect to other pages. Always use the canonical, non-redirect URL.
- Mixing Hreflang with Wrong Canonical Tags: If your canonical tag points to a different URL than what your hreflang specifies, Google will get confused. Your hreflang URL and canonical URL should match on each page.
- Only Adding Tags to Some Pages: If you add hreflang to your homepage but not your blog posts or product pages, you only get partial benefit. Hreflang should be applied consistently across all translatable content.
Hreflang Tags and WordPress Multisite
WordPress Multisite is a feature that lets you run multiple WordPress sites from a single installation. It is commonly used for multilingual setups, where each language version has its own sub-site (e.g., example.com, es.example.com, fr.example.com).
In a Multisite environment, hreflang implementation works a little differently because the sites are technically separate WordPress installations sharing a core. WPML has a dedicated Multisite solution. You can also use the MultilingualPress plugin, which is designed specifically for Multisite hreflang management.
Using MultilingualPress for WordPress Multisite
- Set up your WordPress Multisite network.
- Install and activate MultilingualPress as a network plugin.
- In the Network Admin, go to MultilingualPress > Modules and enable relevant features.
- For each site in your network, go to My Sites > Network Admin > Sites and edit the site. Under the MultilingualPress tab, assign the language for that site.
- When creating content, you can link posts across sites. MultilingualPress will automatically generate the correct hreflang tags pointing between the different sub-sites.
Best Practices for Multilingual SEO Beyond Hreflang
Hreflang tags are a critical piece of international SEO, but they are not the only piece. Here are additional best practices to maximise your multilingual SEO performance:
Use Human Translators, Not Just Machine Translation
Google can detect machine-translated content that reads unnaturally. Poor translations damage user experience and reflect badly on your site’s quality. Invest in professional human translation or at least have a native speaker review machine-translated content before publishing.
Do Separate Keyword Research for Each Language
Translating your English keywords directly into another language often does not work well. People in different countries search differently. A keyword that works perfectly in English may have a completely different popular phrasing in Spanish or French. Use tools like Google Keyword Planner, Ahrefs, or Semrush in the target language and region to find the terms your actual audience uses.
Set the lang Attribute on the HTML Tag
Every language version of your site should have the lang attribute set on the <html> tag. For example:
<html lang=”es”>
Most WordPress multilingual plugins handle this automatically. It helps search engines and screen readers identify the page language.
Localise More Than Just the Text
Truly effective localisation goes beyond word-for-word translation. Consider:
- Adapting images and visuals to reflect the local culture
- Using local currencies, date formats, and measurement units
- Adjusting references to holidays, events, and local customs
- Localising your calls to action and sales copy to suit the market
- Ensuring contact details and support options are relevant to the region
Submit Your Multilingual Sitemap to Google Search Console
After setting up hreflang and generating your multilingual sitemap, submit it to Google Search Console. This accelerates crawling and indexing of your translated pages. You may want to add each subdirectory or subdomain as a separate property in Search Console to monitor performance for each language version individually.
Troubleshooting Hreflang Issues in WordPress
If your hreflang tags are not working as expected, here is a structured troubleshooting approach:
Problem: Hreflang Tags Are Not Appearing in the Source
- Check that your multilingual plugin (WPML, Polylang) is activated.
- Confirm the hreflang output option is enabled in the plugin settings.
- Clear your WordPress cache. Caching plugins can serve old HTML that does not reflect recent changes.
- Deactivate other plugins one by one to check for conflicts.
Problem: Google Search Console Shows Hreflang Errors
- Check that every referenced page is actually live and returns a 200 status code.
- Verify that the reciprocal tags are in place – each page must reference all others.
- Make sure language codes are correctly formatted (e.g., “en-US” not “en_US” – use hyphens, not underscores).
- Ensure you are not accidentally blocking any language versions in robots.txt.
Problem: Wrong Language Appearing in Search Results
- Verify the hreflang tags are actually present and correctly configured.
- Check that geotargeting is set up correctly in Google Search Console under Legacy Tools > International Targeting.
- Be patient – it can take several weeks for Google to fully process and apply hreflang changes after a major setup or update.
Quick Comparison: Hreflang Implementation Methods
Here is a summary to help you choose the best approach for your WordPress site:
| Method | Difficulty | Cost | Auto Tags | Best For |
|---|---|---|---|---|
| WPML | Easy | Premium | Yes | Professional sites, complex multilingual |
| Polylang | Easy | Free | Yes | Small-medium sites, budget-friendly |
| Rank Math | Easy | Free/Pro | With plugin | Existing Rank Math users |
| Manual (functions.php) | Advanced | Free | No | Developers, small sites |
| XML Sitemap | Medium | Free | With plugin | Large sites, many pages |
| WordPress Multisite | Advanced | Varies | With plugin | Enterprise, separate teams |
Conclusion
Adding hreflang tags to your WordPress site is one of the most important steps you can take if you want to grow your international audience through search engines. Without them, all your hard work creating multilingual content may go unnoticed by the very people you are trying to reach.
The great news is that WordPress makes this remarkably manageable. Whether you choose WPML for a full-featured premium experience, Polylang for a free and capable alternative, or a manual approach for maximum control – there is a method that fits your skill level and budget.
The core principles to remember are simple: always self-reference, always make the tags bidirectional, always include x-default, use correct language and region codes, and test your implementation with reliable tools. Follow these rules consistently and Google will have no trouble serving the right content to the right audience.
Multilingual SEO is an investment that pays dividends over time. As your translated content gets indexed and your hreflang signals build trust with Google, you will see more qualified visitors from your target regions, lower bounce rates, and higher engagement across every language version of your site.
Start with the method that feels most comfortable for you today, verify your implementation, and keep refining. Your international audience is out there – hreflang tags make sure they can find you.
About the Author
Jay Patel is the Founder of XSquareSEO, a full-service SEO agency with experience in on-page SEO, eCommerce SEO, link building, technical SEO, SaaS SEO, and local SEO. For more information, feel free to contact us.
Explore More Guides
Local SEO City Names
AI Predictive SEO Tools
Hardest SEO Industries
Keyword Research Importance
Google AI SEO Issues
SEO Audit Benefits
H1 Tag Ranking Impact
Cloudflare Captcha WordPress
Add Coupons WordPress Products
WordPress Download Button
