Bug description
autoGenerate: true does not regenerate the sitemap when a document is published or unpublished in Strapi 5.
The autoGenerateMiddleware in the sitemap addon only watches ["create", "update", "delete"]. In Strapi 5, publish and unpublish are separate document service actions and do not go through update, so they are silently skipped and the sitemap is never regenerated.
The sitemap only updates on the next cron tick — not immediately after publishing.
Steps to reproduce
- Configure
autoGenerate: true in config/plugins.ts
- Create a new article (saved as draft)
- Publish the article
- Immediately check
/api/sitemap/index.xml — the article is not present
- Wait for the next cron run — the article appears correctly
Root cause
In packages/addons/sitemap/server/src/middlewares/auto-generate.ts:
if (!["create", "update", "delete"].includes(action)) {
return next(); // publish and unpublish fall through here and are ignored
}
In Strapi 5, publish and unpublish are first-class document service actions (not aliases for update), so they never reach the sitemap generation logic.
Expected behaviour
Sitemap regenerates immediately after a document is published or unpublished, without waiting for the next cron tick.
Fix
Add "publish" and "unpublish" to the action allowlist:
if (!["create", "update", "delete", "publish", "unpublish"].includes(action)) {
return next();
}
Environment
webtools-addon-sitemap: 1.3.1
strapi-plugin-webtools: 1.10.0
- Strapi: 5.x
Related
Bug description
autoGenerate: truedoes not regenerate the sitemap when a document is published or unpublished in Strapi 5.The
autoGenerateMiddlewarein the sitemap addon only watches["create", "update", "delete"]. In Strapi 5,publishandunpublishare separate document service actions and do not go throughupdate, so they are silently skipped and the sitemap is never regenerated.The sitemap only updates on the next cron tick — not immediately after publishing.
Steps to reproduce
autoGenerate: trueinconfig/plugins.ts/api/sitemap/index.xml— the article is not presentRoot cause
In
packages/addons/sitemap/server/src/middlewares/auto-generate.ts:In Strapi 5,
publishandunpublishare first-class document service actions (not aliases forupdate), so they never reach the sitemap generation logic.Expected behaviour
Sitemap regenerates immediately after a document is published or unpublished, without waiting for the next cron tick.
Fix
Add
"publish"and"unpublish"to the action allowlist:Environment
webtools-addon-sitemap: 1.3.1strapi-plugin-webtools: 1.10.0Related