From 414d4f98a184781bfeaa1603f8aab88b154ef031 Mon Sep 17 00:00:00 2001 From: Huy Le Date: Tue, 7 Jun 2022 07:43:00 +0000 Subject: [PATCH] [FIX] website: `og:url` should be localized Before this commit, with a website using multiple languages, when sharing any links with a language other than the original language on Facebook, the content of Optimize SEO always receives the value of the default language. The reason is that `og:url` does not change according to the language of the website because it's using `http.httprequest.url`. Note that `http.httprequest.url` doesn't contain the lang part since we already went through the dispatch's rerouting. So we need to localize `og:url` to fix this. Steps to reproduce: 1. Set up 2 different languages for your website (e.g. English, Vietnamese). Set the default language for the website to English. 2. Create any page, promote seo page for both languages. 3. Share this link on Facebook with Vietnamese language, see the title and description on preview are still in English. closes odoo/odoo#93998 X-original-commit: d47a2e4d08110df380c0060eebb1e9c2924b523e Signed-off-by: Romain Derie (rde) --- addons/website/models/mixins.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/website/models/mixins.py b/addons/website/models/mixins.py index 1fb1ea2cb73..623721dc900 100644 --- a/addons/website/models/mixins.py +++ b/addons/website/models/mixins.py @@ -56,7 +56,7 @@ class SeoMetadata(models.AbstractModel): 'og:type': 'website', 'og:title': title, 'og:site_name': company.name, - 'og:url': request.httprequest.url, + 'og:url': url_join(request.httprequest.url_root, url_for(request.httprequest.path)), 'og:image': request.website.image_url(request.website, img_field), } # Default meta for Twitter