2

Is it possible for a page to include multiple link tags using the hreflang attribute for different languages but all actually pointing to the same URL since the language detection and related content delivery for that page is done at the Apache level? (I suppose the same could be said for a dynamic page, say PHP, that delivers content in different languages.)

My site setup uses a combination of MultiView and AddLanguage so that when loading the URL host/folder/page, Apache actually serves host/folder/page.<lang>.html meaning that the page content can be in either English or French depending on the browser language settings but the URL to load stays the same, which is the way I like it.

Many answers I've looked at here only consider a language subdomain or subfolder but that's not my case as the URL is the same for all languages. Can I index this properly by using multiple hreflang, or what else?

Example:
htp://www.nicealias.com/articles/focus_on_renewables.en.html and
htp://www.nicealias.com/articles/focus_on_renewables.fr.html
can be loaded by using just
htp://www.nicealias.com/articles/focus_on_renewables

so can I simply use both of these tags together

<link rel="alternate" href="http://www.nicealias.com/articles/focus_on_renewables" hreflang="en">
<link rel="alternate" href="http://www.nicealias.com/articles/focus_on_renewables" hreflang="fr">

in each page, given that Apache will take care of serving the right content?

1

Different language codes can point to the same page but the way you want to use it is wrong.

This is fine:

<link rel=alternate hreflang="en-US" href="http://example.com/en/">
<link rel=alternate hreflang="en-GB" href="http://example.com/en/">

But your example is not. Think about it -- we all WANT search engines to crawl all language versions of our pages. But your proposed markup is making it impossible for search engines to crawl and view your English and French content. When Googlebot crawls your page, it will get the English version. It will detect that the French version is also on the same page (!) but won't find any French content.

The solution to what you are doing is x-default. x-default is a special value of hreflang that is used to point to a page that does the auto-detection and redirection. So you should have 3 separate URLs:

  1. x-default: That does the auto-redirection to the English or French version as appropriate.
  2. en: The English version
  3. fr: The French version.

Having 3 URLs will let Google crawl all your versions and index them. And when Google knows the user's search preference, they will show the appropriate (EN/FR) page in their search results. When Google doesn't know the user's preference, they will show the x-default page so the user can choose their own language.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.