flexweg-sitemaps
The flexweg-sitemaps plugin owns everything XML-sitemap and robots.txt related on your public site. It generates per-year sitemaps, a sitemap index, an optional Google News sitemap, and the robots.txt that points search engines to all of them.
What it generates
When a post is published / unpublished / deleted, or when you click Force regenerate, the plugin uploads:
| File | Path on Flexweg | Purpose |
|---|---|---|
sitemap-<year>.xml | /sitemaps/sitemap-2025.xml, /sitemaps/sitemap-2026.xml, … | One per calendar year that has online content |
sitemap-index.xml | /sitemaps/sitemap-index.xml | Master index listing every yearly sitemap (+ news when enabled) |
sitemap-news.xml | /sitemaps/sitemap-news.xml | Google News urlset — articles modified within the configured window |
sitemap.xsl | /sitemaps/sitemap.xsl | Browser stylesheet (transforms .xml into a styled HTML table when opened directly) |
sitemap-news.xsl | /sitemaps/sitemap-news.xsl | Same for the news sitemap |
robots.txt | /robots.txt | Site root — points crawlers at sitemap-index.xml |
The yearly bucket is computed from post.createdAt (fallback publishedAt then updatedAt). A post moved between years across publishes gets its old year's sitemap rewritten without it and the new year's sitemap rewritten with it.
Settings
/settings/plugin/flexweg-sitemaps exposes:
- Content types —
posts onlyorposts + pages. Pages bypasssitemap-news.xmlregardless (News is for article-style content). - Google News — toggle + lookback window in days (default 2). When on,
sitemap-news.xmllists every post modified within the window with<news:news>metadata. robots.txtbody — free-form textarea. Blank means use the generated default, which always referencessitemap-index.xml(+sitemap-news.xmlwhen News is enabled).- Insert default button — pre-fills the textarea with the auto-generated content so you can edit instead of starting from scratch.
- Upload stylesheets button — re-uploads only the two XSL files (
sitemap.xsl+sitemap-news.xsl). Useful after switching the admin UI language since the XSL labels are localised fromsettings.language. - Force regenerate button — full pass: XSL + every yearly sitemap + index + news +
robots.txt.
How it hooks in
The plugin subscribes to three lifecycle actions:
api.addAction("publish.complete", regenerate);
api.addAction("post.unpublished", regenerate);
api.addAction("post.deleted", regenerate);
Each invocation calls regenerateForPost with the post that was just touched plus the patched PublishContext (so the corpus already reflects the post-transition state). The handler:
- Determines the affected year from
post.createdAt. - Rewrites that year's sitemap (or deletes it if the year emptied out).
- Rewrites
sitemap-index.xml. - When News is enabled, rewrites
sitemap-news.xml.
A failure (Flexweg unreachable, etc.) is caught + logged so it never aborts the surrounding publish flow. The error still surfaces as a toast through flexwegApi's funnel.
It also registers a Regeneration target so Themes → Regenerate site → Sitemaps runs the same full pass as the Force regenerate button.
When skipped
settings.baseUrlis empty — sitemap entries need an absolute origin. The plugin logs a warning and exits without uploading.- The yearly sitemap would be empty — the year file is
deleteFile'd (and removed from the index) instead of being uploaded as an empty document.
Legacy-root cleanup
An earlier version of the plugin uploaded sitemaps at the site root (/sitemap-index.xml, /sitemap-2025.xml, …). Both Force regenerate and Upload stylesheets run an idempotent sweep that deleteFile's the old root paths. 404s are silent so the sweep is free to run on every full regen.
Per-post incremental hooks skip the sweep to stay fast (only the affected year + index + news get touched).
Toggle
Plugins → Plugins tab → flexweg-sitemaps card → Enable / Disable.
Disabling does not delete files already on Flexweg. To clean up after a disable, use Flexweg's file manager directly to remove /sitemaps/ + /robots.txt.
When changes apply
| Action | Files updated | Latency |
|---|---|---|
| Publish a post | Affected year + index + news | Within seconds |
| Unpublish / delete | Same (or year deleted if it empties out) | Within seconds |
Edit robots.txt body in settings | /robots.txt | On Save |
| Toggle News on/off | sitemap-news.xml + index | On Force regenerate |
| Switch admin language | XSL stylesheets | On Upload stylesheets click |
Internal details
- Source:
src/plugins/flexweg-sitemaps/ - External in production builds: yes
- Hooks used:
publish.complete,post.unpublished,post.deletedactions +registerRegenerationTarget - Storage path on Flexweg:
/sitemaps/+/robots.txt(root) - Translations: 7 locales (matches admin)
Continue
- RSS feeds plugin
- Site features: Sitemaps — what the resulting files look like to crawlers
- Settings → Plugin settings