Issue
- When we look for our page in Google search, some of the listed results has a locale we don't even use.
- What can we do to resolve that and have the URL with the correct locale in the search results?
Environment
- Liferay DXP 7.4 and Quarterly Releases
- Liferay Portal 6.2, Liferay DXP 7.0, 7.1, 7.2, 7.3
Resolution
- What you see in the Google search results is originated from Google's indexing mechanism.
- If there are a lot of languages in your Language settings' Current languages, your page source will contain a lot of localizations in the canonical URLs. The URL with the other localization has been indexed by Google for some reason that stuck in the search results
Also, verify the following:
- Request locale enabled:
- Verify the value of the following portal-ext property:
-
locale.default.request=false
- If this property is activated (true), Liferay will try to determine the client's locale from the request.
- Otherwise, It will set the default value from the JVM.
- JVM startup country/language:
- For example, you can set a custom language in setenv.sh adding this line (Spanish):
-
CATALINA_OPTS="$CATALINA_OPTS -Duser.country=ES -Duser.language=es"
- Restrict your scope languages:
- If you only use a specific language in your portal/instance/site then we would suggest you removing every language besides that one from the current Languages settings.
-
Check locale prepend friendly URL style
- Having one specific URL for each language can be useful to avoid this issue.
-
Simulate a request without adding language header to get the default language.
-
# Should return the content in the expected default locale (e.g. es_ES).
curl <home-url>
# Browser's locale
curl --header 'Accept-Language: es-es' <home-url> - The issue could be reproduced If accept language header is needed to load the content in the default locale.
-
- After you have checked everything, you can request to recrawl your website, however, it should be done automatically after some time.