Skip to content

[18.0][ADD] website_exclude_sitemap - #1177

Open
edescalona wants to merge 1 commit into
OCA:18.0from
BinhexTeam:18.0-add-website_exclude_sitemap
Open

[18.0][ADD] website_exclude_sitemap#1177
edescalona wants to merge 1 commit into
OCA:18.0from
BinhexTeam:18.0-add-website_exclude_sitemap

Conversation

@edescalona

@edescalona edescalona commented Apr 17, 2026

Copy link
Copy Markdown

@BinhexTeam

T21540

Context

Odoo includes every public website URL in the generated sitemap. Some of those URLs are useful for direct navigation but add little or no SEO value when exposed in /sitemap.xml (/livechat, feeds, apply forms, user profiles...). This module keeps the sitemap focused on strategic public pages while leaving normal website access untouched.

What it does

  • Adds a per-website sitemap_excluded_paths text field, editable from Website > Configuration > Settings > Sitemap Exclusions.
  • Overrides website._enumerate_pages() to drop the entries whose path matches one of the configured patterns.
  • Clears the cached sitemap attachments when the exclusions change, when website.page records are created or deleted, and when their url, website_published, website_indexed, date_publish or website_id changes.
  • Adds a Reload Sitemap button to clear the sitemap cache of the current website manually.

The module only affects sitemap generation: it does not unpublish pages, change access rights, or block direct access to the excluded URLs.

Pattern syntax

Values are separated by line breaks, commas or semicolons; lines starting with # are comments.

Pattern Matches Does not match
/livechat /livechat /livechat/room
/customers/ /customers, /customers/acme, /customers/acme/2024 /customers-list
/blog/*/feed /blog/news/feed /blog/a/b/feed, /blog/news
/solutions* /solutions, /solutions-cloud /solutions/cloud
/jobs/** /jobs, /jobs/apply/1, /jobs/a/b/c /jobs-list
  • * matches inside a single path segment and never crosses a /.
  • ** crosses /, matching any number of segments.
  • A pattern ending in / or /** is a prefix: it excludes that path and everything below it.
  • Any other pattern matches that exact path; the trailing slash of the URL is ignored.

The default value only covers paths present in any Odoo website (/customers/, /livechat, /blog/*/feed, /jobs/apply/, /profile/); deployment-specific paths are meant to be added by the administrator.

Implementation notes

  • Patterns are compiled to regexes cached with tools.ormcache keyed on the raw exclusions text, so they are compiled once per configuration instead of once per sitemap entry.
  • write() on website clears the registry cache when sitemap_excluded_paths changes, so the compiled patterns are invalidated too.
  • Sitemap cache clearing removes the /sitemap-<website_id>-% binary attachments.
  • Pages without website_id (shared across websites) invalidate the sitemap cache of every website.

@OCA-git-bot OCA-git-bot added series:18.0 mod:website_exclude_sitemap Module website_exclude_sitemap labels Apr 17, 2026
@edescalona
edescalona force-pushed the 18.0-add-website_exclude_sitemap branch from 6613e81 to 4fb3741 Compare April 20, 2026 15:29
@edescalona
edescalona marked this pull request as ready for review April 20, 2026 15:37
@github-actions

Copy link
Copy Markdown

There hasn't been any activity on this pull request in the past 4 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days.
If you want this PR to never become stale, please ask a PSC member to apply the "no stale" label.

@github-actions github-actions Bot added the stale PR/Issue without recent activity, it'll be soon closed automatically. label Aug 23, 2026

@rrebollo rrebollo left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please consider my suggestions

Comment thread website_exclude_sitemap/i18n/es_ES.po Outdated

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idem to es.po, so why? Get rid of it.

# Copyright 2026 Binhex <https://www.binhex.cloud>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from odoo import _, fields, models

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
from odoo import _, fields, models
from odoo import fields, models

"type": "ir.actions.client",
"tag": "display_notification",
"params": {
"title": _("Sitemap reloaded"),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"title": _("Sitemap reloaded"),
"title": self.env._("Sitemap reloaded"),

"tag": "display_notification",
"params": {
"title": _("Sitemap reloaded"),
"message": _(

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"message": _(
"message": self.env._(

@github-actions github-actions Bot removed the stale PR/Issue without recent activity, it'll be soon closed automatically. label Sep 6, 2026
@edescalona
edescalona force-pushed the 18.0-add-website_exclude_sitemap branch from 4fb3741 to f6ca34c Compare September 10, 2026 20:18
Let website administrators exclude public URLs from /sitemap.xml through a
per-website list of paths or glob patterns, configured in Website >
Configuration > Settings.

Only sitemap generation is filtered: pages stay published and directly
accessible. The sitemap cache is cleared when the exclusions or the website
pages change, and a Reload Sitemap button clears it manually.
@edescalona
edescalona force-pushed the 18.0-add-website_exclude_sitemap branch from f6ca34c to 24c8346 Compare September 10, 2026 20:24
@edescalona

Copy link
Copy Markdown
Author

Hi @rrebollo , thanks for the review; the suggestions have been applied. @pedrobaeza

@rrebollo rrebollo left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review. LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:website_exclude_sitemap Module website_exclude_sitemap series:18.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants