On websites with pages in several languages, a common practice to improve the user experience is to redirect the website to the page with the user’s browser language if it exists. This practice is penalized by Google for SEO positioning, since it understands that the link is being concealed and deceiving the user to obtain some benefit.
Putting the visitor on the page with the same language of their browser (if that language exists) is a simple practice with little code, since the language of the browser that visits the web is known and can be redirected based on it.
So if the visitor has. For example, the browser in Spanish and our website has another language by default, we can redirect the user to the Spanish page, if it exists, or go to the page configured with the default language.
The variable HTTP_ACCEPT_LANGUAGE in its first two characters gives us the language:
substr($_SERVER["HTTP_ACCEPT_LANGUAGE"],0,2)
and with this, if we have said language on our website, we can redirect you to it.
If we use the WPML translation plugin we can automate this process simply by indicating it in said plugin in its settings:
or disable it to avoid Google penalty.
In this situation, the option we have left is to enable a selector or button that allows the user to change the language once they join the web, suggesting the language of their browser.
Google advises that users be allowed to change languages. Thus, if there are several page versions, it indicates that hyperlinks must be added to other language versions of the page, allowing the user to select the desired language. And avoid automatically redirecting the user based on the detected language, because this may prevent the user and search engines from seeing all versions of that page.
Our proposal is to add a plugin that automates this process in WordPress that uses the WPML translation plugin.
Here we provide you with the link to this plugin, which is available for free on our website. Download and install on your WordPress website. Once installed, activate it and you will be able to configure the format and the text that will appear as a bar when a user enters the web, suggesting the language to change to if it exists in the WPML translations.