Html lang attribute wrong value when using "set locale from accept language header"

We are trying to list some of our products on AppSource of Microsoft. They require an all English experience for listing. However, our forums are bilingual and I want to include a link to the English category on the AppSource listing.

We have enabled “set locale from accept language header” to allow people from India to see the secondary content in English (“Last topics” instead of “Laatste nieuwsberichten” - Dutch).

However, when testing with Postman and Accept-Language switching from “nl” to “en”, the generated HTML is incorrect:

With en:

<!DOCTYPE html>
<html lang="nl">

<head>

With nl:

<!DOCTYPE html>
<html lang="nl">

<head>

The actual labels are correctly changed from Dutch to English, but the html tag still lists the language as Dutch instead of the language of the content.

A test was also run from Locale-Adaptive Pages Testing Tool | TechnicalSEO.com with identical outcome:

It would be good for indexability when the lang attribute could be set either from the accept-language or derived from the category for Google. Please remember that Google crawls from US typically with Accept-Language set.

Just to be clear, is the issue that you are describing only happening with crawlers and API requests?

From Google’s documentation:

In addition, the crawler sends HTTP requests without setting Accept-Language in the request header.

Since Google doesn’t set the Accept-Language header, that approach isn’t going to work to solve the issue with Google.

The html tag’s lang attribute is always set to the site’s default locale. This is also the case when a user selects a locale other than the site’s default locale from their preferences page.

2 Likes

I am sorry. Maybe I pasted the wrong URL. See Crawling and indexing of locale-adaptive pages

Since 2015 Google supports crawling with accept language.

1 Like