Skip to main content

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:

FilePath on FlexwegPurpose
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.xmlMaster index listing every yearly sitemap (+ news when enabled)
sitemap-news.xml/sitemaps/sitemap-news.xmlGoogle News urlset — articles modified within the configured window
sitemap.xsl/sitemaps/sitemap.xslBrowser stylesheet (transforms .xml into a styled HTML table when opened directly)
sitemap-news.xsl/sitemaps/sitemap-news.xslSame for the news sitemap
robots.txt/robots.txtSite 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 typesposts only or posts + pages. Pages bypass sitemap-news.xml regardless (News is for article-style content).
  • Google News — toggle + lookback window in days (default 2). When on, sitemap-news.xml lists every post modified within the window with <news:news> metadata.
  • robots.txt body — free-form textarea. Blank means use the generated default, which always references sitemap-index.xml (+ sitemap-news.xml when 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 from settings.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:

  1. Determines the affected year from post.createdAt.
  2. Rewrites that year's sitemap (or deletes it if the year emptied out).
  3. Rewrites sitemap-index.xml.
  4. 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.baseUrl is 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

ActionFiles updatedLatency
Publish a postAffected year + index + newsWithin seconds
Unpublish / deleteSame (or year deleted if it empties out)Within seconds
Edit robots.txt body in settings/robots.txtOn Save
Toggle News on/offsitemap-news.xml + indexOn Force regenerate
Switch admin languageXSL stylesheetsOn Upload stylesheets click

Internal details

  • Source: src/plugins/flexweg-sitemaps/
  • External in production builds: yes
  • Hooks used: publish.complete, post.unpublished, post.deleted actions + registerRegenerationTarget
  • Storage path on Flexweg: /sitemaps/ + /robots.txt (root)
  • Translations: 7 locales (matches admin)

Continue