Repository navigation
Add SEO management: robots.txt and XML sitemaps - #933
aXenDeveloper wants to merge 2 commits into
Conversation
…ontrols
robots.txt
- /robots.txt is generated by the API: private areas (/admin, /settings,
/modcp, /notifications, /files) disallowed in every language, an optional
group blocking AI training crawlers, custom rules and the Sitemap line.
- "Allow search engines to index this site" off turns it into
`Disallow: /` and makes every sitemap answer 404 (staging kill switch).
- While the site is offline it answers 503 with Retry-After, so crawlers
pause instead of dropping pages.
Sitemaps
- /sitemap.xml is a sitemap index; /sitemaps/{source}-{page}.xml are its
chunked files (URLs per file configurable, default 10,000), with
xhtml:link hreflang alternates and image:image only when used, strict
XML escaping and Cache-Control: public, max-age=3600, s-maxage=3600,
stale-while-revalidate=86400.
- Sitemap registry: core `static` source (/, plugin and app paths,
localized with x-default), one source per Content Engine type with
delivery.sitemap, `buildApiPlugin({ sitemap })`,
`buildApiConfig({ seo })`, `registerSitemapSource`,
`defineSitemapSource` and `staticSitemapSource`. Ids are validated
against /^[a-z0-9_-]+$/ and duplicates fail at boot.
- Content sources list only published, guest-readable, not-noIndex records
at their current slug, one URL per published translation, ordered by id,
selecting only id, slug, timestamps and the cover image id.
- Blog and forum add /blog and /forum; apps/web adds its marketing pages
and a docs source, replacing the static public/robots.txt and
public/sitemap.xml.
- robots.txt, sitemap.xml and /sitemaps are never locale-prefixed.
AdminCP
- System -> SEO with "General & robots.txt" (indexing, AI crawlers,
custom rules, live preview) and "Sitemaps" (enable, URLs per file,
sources table with URL counts, preview links and per-source switches).
- New `seo` staff permissions (can_view, can_manage), core_seo_settings
table and migration, GET/PATCH /admin/seo/settings,
GET /admin/seo/robots/preview, audit log entries and the
seo.settings.updated event.
Web
- `@vitnode/core/tanstack/seo/server` handlers and root route files in
apps/web and the create-vitnode-app template.
Docs
- New "Robots and sitemaps" and "Sitemap sources" pages, Content Engine
SEO sitemap section rewritten, SEO events documented.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CnAiFZNJNobrZC6R2qu7sj
…routes - Pure functions: buildRobotsTxt/normalizeCustomRobots, parseSitemapFileName, sitemapPageCount, sitemapUrlsetXml, defineSitemapSource, mergeSeoSettings, resolveSeoConfig and staticSitemapEntries on a real locale routing. - Public routes on the in-memory database: headers, 404s when indexing or sitemaps are off, a source is disabled or a page is out of range, and 503 with Retry-After while the site is offline. - AdminCP routes: 403 without the seo permission, 400 for an unknown source, and a disabled source leaving the index and its file at once. - contentSitemapSource: drafts, scheduled, hidden, noIndex (null included) and guest-restricted records are left out; localized types list each published translation with hreflang alternates and x-default. - memory-db: evaluate IS [NOT] DISTINCT FROM, which the sitemap's noIndex condition uses. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CnAiFbAM6TCSyfasoERNUE
|
Hey there and thank you for opening this pull request! 👋🏼 We require pull request titles to follow the Conventional Commits specification and it looks like your proposed title needs to be adjusted. Details: |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
React Doctor found no new issues. 🎉 Reviewed by React Doctor for commit |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ef42bcbee2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| onToggle={async (source, enabled) => { | ||
| const disabled = new Set( | ||
| data.settings.sitemap.disabledSources, | ||
| ); |
There was a problem hiding this comment.
Serialize source toggles or disable conflicting switches
If an administrator switches off two sources before the first save completes, both handlers build their replacement disabledSources array from the same stale data. Starting with no disabled sources, the requests send [A] and [B], so the last save silently re-enables the other source even though both actions report success. SourceSwitch only disables itself, leaving sibling switches active. Track pending state at the table/screen level and disable conflicting controls, or serialize updates against the latest saved state, as required by the action-loading guidance in AGENTS.md.
AGENTS.md reference: AGENTS.md:L46-L46
Useful? React with 👍 / 👎.
| const admin = c.get("admin"); | ||
| if (!admin) throw new HTTPException(403); | ||
|
|
||
| const next = mergeSeoSettings(await loadSeoSettings(c), body); |
There was a problem hiding this comment.
Merge partial settings updates under the database lock
When two administrators save different settings concurrently, both requests can load the same settings here and compute complete replacement objects before either transaction commits. Although saveSeoSettings subsequently locks the row, it writes every field from that already-computed object rather than merging with the locked row. For example, a sitemap-settings save can undo another administrator's concurrent allowIndexing: false update despite omitting that field from its PATCH. Read and merge the partial update inside the transaction against the locked database state, rather than using the cached pre-transaction settings.
Useful? React with 👍 / 👎.
Description
What?
Adds comprehensive SEO management to VitNode, enabling admins to control
robots.txtgeneration and XML sitemaps through the AdminCP without code changes. This includes:Dynamic robots.txt generation served at
/robots.txtwith configurable:/admin,/settings,/modcp,/notifications,/files)XML sitemap infrastructure served at
/sitemap.xml(index) and/sitemaps/{source}-{page}.xml(sub-sitemaps) with:delivery.sitemapis enabled)AdminCP interface at System → SEO with tabs for:
Database schema (
core_seo_settingstable) to persist settings with audit loggingWhy?
SEO is critical for discoverability. Previously, VitNode had a static sitemap and no robots.txt control. This implementation:
Test Plan
Added comprehensive test coverage:
sitemap.test.ts: Sitemap XML generation, file naming, paginationrobots.test.ts: robots.txt building, AI crawler blocking, custom rules normalizationstatic-source.test.ts: Static page sitemap entries with locale routingsitemap-source.test.ts: Content type sitemap generation with publication/access filteringconfig.test.ts: SEO config resolution and source orderingsettings.test.ts: Settings merging and validationseo.route.test.ts: HTTP endpoints for robots.txt and sitemaps with caching and offline handlingseo.route.test.ts(admin): Admin API for reading/updating settings with permissionsExisting content delivery tests updated to support new sitemap conditions.