Tell me how to make google correctly determine the page language? The site is in two languages: fr and eng. In fr google issued title and description in English. In Google search correctly gives a link to the French page, but (!) The title and description displays from the English version. PHP site with MySQL.

Example: looking for a site in google on fr, google shows the result with a link to the fr page, but with a description in english. I click on the link, go to the fr page, look at the code, Description and Title in French, as it should be, but Google shows them in English!

I watched Google recommendations, did as Google recommends.

  • tags link rel hreflang are both in French and English versions of pages. HTML:

  • The lang tag is on the HTML pages:

  • SiteMap.xml has been added to the Google Search Console with HTML tags:

At the beginning of the php page, assign values ​​to variables depending on the language: en or fr: PHP:

if($_SESSION["lang"] == "en") { $atitleMf = "Заголовок на англ"; $adescription = "Описание на англ."; } else { $atitleMf = "Заголовок на фр"; $adescription = "Описание на англ."; } 

In the head tag:

 <title><?= $atitleMf; ?></title> <meta name="description" content="<?= $adescription; ?>"> 

There is a suspicion that Google doesn’t like something about how the description and title values ​​are assigned ..

Is it correct? How can I make Google display the title and description correctly? in English for English Google, in French for Google Google.

  • Can I link to the French and English versions? I think google considers both versions as one site. here you can insert a link to your site and see how the robot sees it. Insert both your versions one by one and see. - shadow

1 answer 1

Google is a robot. Do not use sessions, but the $_SERVER['HTTP_ACCEPT_LANGUAGE'] header to determine the language.

When the robot enters your page, it sees only the default version.

  • What will be the difference for google $ _SERVER ['HTTP_ACCEPT_LANGUAGE'] and session? Does Google care about php? I understand that he indexes pages in html, and in order to index them he has SiteMap, because the URL for the French and English versions are different .. - Ivan