[IMP] website - add noindex when not browsing configured domain

Description of the issue/feature this PR addresses:
Currently, search engines index a SAAS-hosted website twice
(once for the actual domain, and once for the .odoo.com domain)
which is something that should be preventable.

Desired behavior after PR is merged:
If a domain name is configured, and the website is accessed
through a different domain than the configured one, the noindex
tag appears, preventing crawlers from indexing it..

task-2418904

closes odoo/odoo#78425

Signed-off-by: Romain Derie (rde) <rde@odoo.com>
This commit is contained in:
Kamen Zhekov
2021-10-21 16:54:43 +00:00
committed by Romain Derie
parent ab523354fa
commit 3739d74afe
+7 -2
View File
@@ -69,8 +69,8 @@
<meta name="generator" content="Odoo"/>
<t t-set="website_meta" t-value="seo_object and seo_object.get_website_meta() or {}"/>
<meta name="default_title" t-att-content="default_title" groups="website.group_website_designer"/>
<meta t-if="main_object and 'website_indexed' in main_object
and not main_object.website_indexed" name="robots" content="noindex"/>
<meta t-if="(main_object and 'website_indexed' in main_object
and not main_object.website_indexed) or (website.domain and website.domain not in request.httprequest.url_root)" name="robots" content="noindex"/>
<t t-set="seo_object" t-value="seo_object or main_object"/>
<t t-set="meta_description" t-value="seo_object and 'website_meta_description' in seo_object
and seo_object.website_meta_description or website_meta_description or website_meta.get('meta_description', '')"/>
@@ -2309,6 +2309,10 @@
<template id="robots">
<t t-translation="off">
User-agent: *
<t t-if="website.domain and website.domain not in url_root">
Disallow: /
</t>
<t t-else="">
Sitemap: <t t-esc="url_root"/>sitemap.xml
@@ -2318,6 +2322,7 @@ Sitemap: <t t-esc="url_root"/>sitemap.xml
<t t-out="request.website.sudo().robots_txt" />
</t>
</t>
</template>
<template id="sitemap_locs">