Language / Region URL
HTML <head> tags
XML Sitemap snippet

What is hreflang?

The hreflang attribute tells Google which language version of a page to serve based on a user's locale. Without it, Google may treat multilingual pages as duplicates or surface the wrong language version in search results.

When to use x-default?

x-default designates the fallback URL shown to users whose locale doesn't match any variant, typically a language-selector page or your primary landing page. Every hreflang set should include one.

Where to Place hreflang Tags

You can implement hreflang in one of three ways. If you use more than one method, make sure they are consistent:

Language vs. Region: Is the Region Necessary?

The simple answer is no, the region code is not mandatory. However, the language code is strictly required.

1. The Mandatory Component: Language

You must always specify a language using the ISO 639-1 format (e.g., en, es, fr). If you only have one version of your site for all Spanish speakers globally, you should use hreflang="es". Adding a region in this case (like es-ES) would unnecessarily limit your reach because it would tell Google that the page is only for people in Spain, potentially hurting your visibility in Mexico or Argentina.

2. The Optional Component: Region

The region code (ISO 3166-1 alpha-2) is an optional modifier. You should only use it when you have different content for people who speak the same language but live in different places.

3. The Golden Rule of Syntax

You can have a language alone, but you cannot have a region alone.

Format Status Example
Language Only Valid hreflang="en"
Language + Region Valid hreflang="en-GB"
Region Only Invalid hreflang="GB"

Best Practices

est. 2024