Skip to content

sitemap: fail the build when a section or its dates go missing - #5870

Merged
ZJvandeWeg merged 2 commits into
mainfrom
sitemap/fail-on-missing-sections
Sep 25, 2026
Merged

ZJvandeWeg merged 2 commits into
mainfrom
sitemap/fail-on-missing-sections

Conversation

@dimitrieh

@dimitrieh dimitrieh commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Description

Two sitemap failures pass silently today:

  • server/api/__sitemap__/content-urls.get.ts catches its own errors, so a collection that fails to query, or a glob that matches nothing, drops that whole section from /sitemap.xml.
  • lib/git-lastmod.mjs returns nothing when git log fails, so every git-dated page loses its lastmod.

This checks the rendered /sitemap.xml at prerender time and fails the build when a content section has no URLs, or when a section dated only from git has no lastmod at all. Blueprints are not required, since a build without access to the private library has none.

Production's current sitemap passes the check. A build with a section that does not exist added to the list fails with [sitemap] no /no-such-section/ URLs.

Related Issue(s)

Follow-up to #5777

Checklist

  • I have read the contribution guidelines
  • I have considered the performance impact of these changes
  • Suitable unit/system level tests have been added and they pass
  • Documentation has been updated
  • For blog PRs, an Art Request has been created (instructions)

content-urls.get.ts catches its own errors, so a collection that fails to query
or a source glob that matches nothing just leaves that section out of
/sitemap.xml. git-lastmod.mjs returns nothing when `git log` fails, so every
git-dated page silently loses its lastmod. Neither failed a build.

A prerender:generate hook now checks the rendered /sitemap.xml and marks the
route as errored, which fails the build under failOnError, when a content
section (docs, handbook, changelog, blog, customer-stories, ebooks, whitepaper)
has no URLs, or when a section dated only from git has no lastmod on any URL.
The blueprints are not required, since a build without access to the private
library has none by design.
@netlify

netlify Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for flowfuse-website ready!

Name Link
🔨 Latest commit af933dc
🔍 Latest deploy log https://app.netlify.com/projects/flowfuse-website/deploys/6ab6d52de30619000782914f
😎 Deploy Preview https://deploy-preview-5870--flowfuse-website.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 43 (🟢 up 12 from production)
Accessibility: 95 (no change from production)
Best Practices: 92 (no change from production)
SEO: 92 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

@dimitrieh

Copy link
Copy Markdown
Contributor Author

FYI: the failing build here isn't caused by this PR. Tracked in https://github.com/FlowFuse/engineering/issues/460. It's resolved now, re-running the checks.

@nuxtjs/sitemap does not prerender /sitemap.xml through Nitro's route loop. It
renders the file itself in prerender:done, so the prerender:generate hook never
saw it and the check never ran. The module passes the rendered sitemaps to the
Nuxt hook sitemap:prerender:done instead, and a throw there fails the build.

Checked by building with a section that does not exist added to the list: the
build fails with "[sitemap] no /no-such-section/ URLs".
@ZJvandeWeg
ZJvandeWeg merged commit 2659865 into main Sep 25, 2026
8 checks passed
@ZJvandeWeg
ZJvandeWeg deleted the sitemap/fail-on-missing-sections branch September 25, 2026 21:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants