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.