Instatic icon indicating copy to clipboard operation
Instatic copied to clipboard

feat(seo): SEO & AEO workspace — metadata model, JSON-LD, robots/sitemap, AI suggestions

Open DavidBabinec opened this issue 5 months ago • 0 comments

What changed

SEO & AEO as a core publishing capability, end to end:

Core model (src/core/seo/, new barrel-gated engine module)

  • Structured SeoMetadata stored in cells_json.seo (one built-in seoMetadata field on page/postType tables — replaces the flat seoTitle/seoDescription fields, no compat path; pre-release).
  • SiteSeoSettings under site.settings.seo (title pattern, description, default social image, X handle/card, Organization, robots, sitemap) — replaces the legacy metaTitle/metaDescription settings.
  • One shared resolver with two-stage title resolution (explicit title → {source.field} token pattern via the existing token engine → base title → site name), used identically by the publisher, the admin previews, and the health indicators.

Published output

  • New src/core/publisher/seoHead.ts: title, description, canonical, noindex (never a silent nofollow), Open Graph (incl. og:locale, og:site_name, article:*_time), X cards, and schema.org JSON-LD (WebSite, Organization, Article, BreadcrumbList) with safe serialization.
  • Absolute URLs come only from the configured PUBLIC_ORIGINS — baked HTML never guesses a host; dynamic endpoints fall back to the request origin.

Crawl files

  • First-party GET /robots.txt and GET /sitemap.xml (server/publish/seoEndpoints.ts), dispatched before static assets/public rendering, generated from the published snapshot and cached per publishVersion.
  • Robots.txt carries two AI-crawler toggles: training bots (GPTBot, Google-Extended, CCBot, Applebot-Extended, meta-externalagent) and answer bots (OAI-SearchBot, PerplexityBot, ChatGPT-User, Claude-SearchBot).

Admin workspace (/admin/tools/seo)

  • New Tools nav dropdown (SEO + plugin admin pages; plugin routes unchanged).
  • Meta tab: target index (search, filters, issue chips, health dots, keyboard nav, pinned Site defaults) + sticky preview editor with Search/OG/X/Schema views, inherited values as placeholders, pixel length meters, media-library image pickers, customize-X gate, dirty-switch guard dialog.
  • Robots.txt tab: toggles over a byte-identical generated preview. Sitemap tab: enable/exclusions with counts.
  • AI suggestions: sparkle on metadata inputs → POST /seo/generate (one tool-less call through the existing server/ai driver stack) → three tappable bubbles with More options / Reject.

API & permissions

  • /admin/api/cms/seo/* route group; new seo.read/seo.manage capabilities; target writes additionally enforce the owning persona (pages.edit / content edit); generate additionally requires ai.chat.

Why

SEO/AEO correctness belongs in the CMS core: metadata emission, structured data, crawl files, and answer-engine controls must work without plugins. Spec was reviewed and hardened first (fallback-chain correctness, publish-lifecycle integration, origin handling, AEO scope).

Impact

  • Local dev DBs need re-seeding (rm -rf .tmp/dev.db or fresh bun run dev) — the seeded built-in field set changed.
  • site.settings.metaTitle/metaDescription are gone; site-wide SEO copy lives in the SEO workspace.
  • 38 core capabilities (was 36); Owner/Admin gain seo.* automatically.

Verification

bun test        # 5438 pass, 0 fail
bun run build   # tsc -b && vite build — clean
bun run lint    # clean

🤖 Generated with Claude Code

DavidBabinec avatar Jun 12 '26 11:06 DavidBabinec