Issue
- Canonical URLs work correctly for pages in different locales, however, users want the same for their products so that the correct canonical tag is displayed for their product based on the page locale.
Environment
- Liferay DXP [all updates]
- Quarterly Release
Resolution
- Follow the below steps:
- Navigate to Control Panel > Instance Settings > Pages
- In the 'VIRTUAL INSTANCE SCOPE' section open the SEO section
- In the 'Canonical URL' option there are two options:
- Use Default Language URL
- Use Localized URL
Selecting "Use Default Language URL" will make all pages use as canonical URL the URL set for the default language of the site. Selecting "Use Localized URL" will set for each localized page the URL corresponding to its language as canonical URL.
Please note: these settings are available at instance as well as system level. Choose as per the use case.
Additional Information
-
The URL is defined in the asset (product) and the site builds the rest of the URLs for the languages configured in the instance. For example for Web content that should be similar to a product, the slug defined in web content is
/w/wc1
, therefore the canonical URL can behttp://localhost/web/guest/w/wc1
, and the rest of the locale will be like this:
<link href="http://192.168.40.58:7400/web/guest/w/wc1" rel="canonical" />
<link href="http://192.168.40.58:7400/zh/web/guest/w/wc1" hreflang="zh-CN" rel="alternate" />
<link href="http://192.168.40.58:7400/es/web/guest/w/wc1" hreflang="es-ES" rel="alternate" />
<link href="http://192.168.40.58:7400/sv/web/guest/w/wc1" hreflang="sv-SE" rel="alternate" />
<link href="http://192.168.40.58:7400/ja/web/guest/w/wc1" hreflang="ja-JP" rel="alternate" />
<link href="http://192.168.40.58:7400/nl/web/guest/w/wc1" hreflang="nl-NL" rel="alternate" />
<link href="http://192.168.40.58:7400/hu/web/guest/w/wc1" hreflang="hu-HU" rel="alternate" />
<link href="http://192.168.40.58:7400/ar/web/guest/w/wc1" hreflang="ar-SA" rel="alternate" />
<link href="http://192.168.40.58:7400/pt/web/guest/w/wc1" hreflang="pt-BR" rel="alternate" />
<link href="http://192.168.40.58:7400/de/web/guest/w/wc1" hreflang="de-DE" rel="alternate" />
<link href="http://192.168.40.58:7400/ca/web/guest/w/wc1" hreflang="ca-ES" rel="alternate" />
<link href="http://192.168.40.58:7400/fi/web/guest/w/wc1" hreflang="fi-FI" rel="alternate" />
<link href="http://192.168.40.58:7400/fr/web/guest/w/wc1" hreflang="fr-FR" rel="alternate" />
<link href="http://192.168.40.58:7400/web/guest/w/wc1" hreflang="en-US" rel="alternate" />
<link href="http://192.168.40.58:7400/web/guest/w/wc1" hreflang="x-default" rel="alternate" />
- For content and widget pages, it is allowed to define a specific canonical URL in the SEO settings, and in the case of the Display page, it is configured in the Product with the FriendlyURL setting.
- When a DPT is used for displaying the product, the canonical is automatically the FriendlyURL of the default locale of the site or instance.