Improving user and search engine experience in international projects with x-default

The x-default is an HTML value for the hreflang attribute in <link> tags. It is used to indicate which page the search engine should treat as the default language when the site is crawled or when a user searches in a language or region not covered by the other hreflang attributes.
This attribute value has been in effect since 2013 on search engines like Google and Yandex.
The x-default value is used to define where the user should land if the website’s content is most relevant to their search intent, but none of the languages configured in the hreflang match the user’s settings or query. Its use is not mandatory but is highly recommended for proper SEO language configuration. It is especially important for international projects, as it is unlikely that a website covers all languages.
In summary, it is a way to direct traffic that does not have a configured language or whose language is not represented in the hreflang setup. It is not an automatic language redirect; it simply indicates what search engines should display.
There are two correct ways to use x-default:
This was the original purpose of this value and is therefore a highly recommended option. From any page, it points to a page that serves as a language selector, allowing the user to choose which language to navigate in.
The x-default can also point to the most recommended language version. Usually, this is English as it is the most international language, but it does not have to be.
For example, a website might have more content in Spanish than in English. You also need to consider the target audience, the languages they speak, and which language they are most likely to understand.
There are countless scenarios. If you have questions about a specific case, you can ask me on my Discord for a general question, or book a consultancy for a personalized solution.
There are different ways to indicate to Google which version is the "default" if the user’s settings do not match the configured hreflangs.
The x-default should be the same across all language versions. It does not make sense for the Spanish version to point to a different x-default than the English page.
The configuration is very similar to the hreflang implementation [Recommended to read this article to better understand x-default]. You simply add the x-default option.
<link rel="alternate" hreflang="en" href="http://hreflang.test/"/>
<link rel="alternate" hreflang="es" href="http://hreflang.test/es"/>
<link rel="alternate" hreflang="x-default" href="http://hreflang.test/"/>
In this example, the x-default is set to the English version, but it could also point to a language selector:
<link rel="alternate" hreflang="en" href="http://hreflang.test/"/>
<link rel="alternate" hreflang="es" href="http://hreflang.test/es"/>
<link rel="alternate" hreflang="x-default" href="http://hreflang.test/language-selector/"/>
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xhtml="http://www.w3.org/1999/xhtml">
<url>
<loc>https://www.hreflang.test/page</loc>
<xhtml:link
rel="alternate"
hreflang="es"
href="https://www.hreflang.test/es/page"/>
<xhtml:link
rel="alternate"
hreflang="en"
href="https://www.hreflang.test/page"/>
<xhtml:link
rel="alternate"
hreflang="x-default"
href="https://www.hreflang.test/language-selector"/>
</url>
</urlset>
Remember that if this is done via the sitemap, the <loc> of all pages must be included, and all versions must be marked from each <loc>. This setup is especially useful for websites with languages spread across different domains.
Implementing via headers can be more complex and cumbersome. It is especially recommended for PDF files and other multimedia content. However, it can be automated in some cases to make the system highly efficient.
Here’s how the example above in the Sitemap would look if implemented from the server by setting headers correctly:
Link: <https://www.hreflang.test/page>; rel="alternate"; hreflang="en",
<https://www.hreflang.test/page>; rel="alternate"; hreflang="x-default",
<https://www.hreflang.test/es/page>; rel="alternate"; hreflang="es"
<If "%{REQUEST_URI} =~ m#^/es/page|^/page#">
Header set Link "<https://www.hreflang.test/es/page>; rel=\"alternate\"; hreflang=\"es\",
<https://www.hreflang.test/page>; rel=\"alternate\"; hreflang=\"en\",
<https://www.hreflang.test/page>; rel=\"alternate\"; hreflang=\"x-default\""
</If>
location ~ ^/(es/page|page)$ {
if ($request_uri ~ ^/(es/page|page)$) {
add_header Link '<https://www.hreflang.test/es/page>; rel="alternate"; hreflang="es",<https://www.hreflang.test/page>; rel="alternate"; hreflang="en",<https://www.hreflang.test/page>; rel="alternate"; hreflang="x-default"';
}
}
For this configuration to work properly, remember to reload or restart NGINX.
As mentioned earlier, although it is not mandatory, it is highly recommended to ensure search engines understand which version is the default if no language is available for the user.
If the URL does not exist or redirects, search engines will not interpret it correctly.
If pages do not have self-referencing hreflang, or if the code is incorrect or pages are not linked correctly, Google and other search engines may not interpret the language specification correctly. The same applies if ISO codes do not match Google’s documentation.
For the first time in my publications, I tested ChatGPT to see if it could help prepare a better article. With such technical data, it remains somewhat disappointing:


There are different tools to check and verify correct implementation:
None of these tools are infallible; all can contain errors and rarely interpret headers, so it is always advisable to check manually.
I currently offer advanced SEO training in Spanish. Would you like me to create an English version? Let me know!
Tell me you're interestedIf you liked this post, you can always show your appreciation by liking this LinkedIn post about this same article.