diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php
index 3e7ddb019a1..6ffebce4688 100644
--- a/htdocs/core/lib/website.lib.php
+++ b/htdocs/core/lib/website.lib.php
@@ -759,7 +759,16 @@ function getSocialNetworkHeaderCards($params = null)
$companyname = str_replace('__WEBSITE_KEY__', $website->ref, $companyname);
$description = str_replace('__WEBSITE_KEY__', $website->ref, $description);
+ $shortlangcode = '';
+ if ($websitepage->lang) {
+ $shortlangcode = substr($websitepage->lang, 0, 2); // en_US or en-US -> en
+ }
+ if (empty($shortlangcode)) {
+ $shortlangcode = substr($website->lang, 0, 2); // en_US or en-US -> en
+ }
+
$fullurl = $website->virtualhost.'/'.$websitepage->pageurl.'.php';
+ $canonicalurl = $website->virtualhost.(($websitepage->id == $website->fk_default_home) ? '/' : (($shortlangcode != substr($website->lang, 0, 2) ? '/'.$shortlangcode : '').'/'.$websitepage->pageurl.'.php'));
$hashtags = trim(join(' #', array_map('trim', explode(',', $websitepage->keywords))));
// Open Graph
@@ -768,7 +777,7 @@ function getSocialNetworkHeaderCards($params = null)
if ($websitepage->image) {
$out .= ''."\n";
}
- $out .= ''."\n";
+ $out .= ''."\n";
// Twitter
$out .= ''."\n";