agentleFS
truemetal74truemetal74/skills/react-seo-ssg/SKILL.md

react-seo-ssg

Skill0 starsChanged 21 days agoMITView on GitHub

Static-site-generation (SSG) prerendering and SEO for the house React/Vite stack — Puppeteer prerenders public routes to static HTML at build time, generates sitemap.xml, and an SEOHead component manages meta tags, Open Graph and JSON-LD structured data. Use this when adding SEO or prerendering to a Vite SPA, when marketing/landing pages need to be crawlable, when asked about sitemaps, meta tags, structured data, or "why doesn't Google see my React page".

  • Installs packages

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    When adding a public page: add the route to prerender.routes.js AND a MUST_CONTAIN entry in prerender.js, or it won't be prerendered, gated …

    line 31

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

SEO + SSG prerendering (house stack)

Vite SPAs render client-side, so crawlers see an empty shell. This skill's approach: after vite build, a Puppeteer script visits each public route on a local server and saves the rendered HTML as dist/<route>/index.html, plus a sitemap.xml. nginx (see deploy-cloudrun skill) serves the prerendered file when it exists, falling back to the SPA — so crawlers get real HTML and users get the normal app.

Files (assets/)

FileCopy toRole
prerender.jsfront-end/prerender.jsServes dist/, visits routes with Puppeteer, saves HTML, writes sitemap.xml, fails the build when a page did not really render. PROJECT CONFIG: SITE_URL, MUST_CONTAIN, MUST_NOT_CONTAIN
prerender.routes.jsfront-end/prerender.routes.jsThe list of public routes to prerender — keep in sync with public routes in App.tsx
SEOHead.tsxsrc/components/seo/SEOHead.tsxPer-page <title>, meta description, canonical URL (from path), Open Graph + Twitter card, and JSON-LD blocks marked data-seo-schema (builders: website, organization, breadcrumbs, faqPage). PROJECT CONFIG: SITE_NAME, SITE_URL, OG_IMAGE

Wiring

  1. npm i -D puppeteer serve-handler
  2. package.json scripts: "build:ssg": "tsc -b && vite build && node prerender.js"
  3. Render <SEOHead title=... description=... path=... schema={...} /> at the top of every public page; prerender waits for these tags before capturing.
  4. Docker: the frontend build stage needs Chromium — the deploy-cloudrun skill's frontend.Dockerfile has the marked block (PUPPETEER_EXECUTABLE_PATH etc.) and uses npm run build:ssg.
  5. When adding a public page: add the route to prerender.routes.js AND a MUST_CONTAIN entry in prerender.js, or it won't be prerendered, gated or listed in the sitemap.

Rules (each one learned from a shipped bug)

  1. Gate every route. A prerender that captures an empty #root still writes a valid file and exits 0. MUST_CONTAIN[route] lists text that only exists once the page really rendered (a headline; for pages that fetch content at runtime, a phrase from that content). A miss fails the build. Never delete a gate to get a build through.
  2. Every prerendered page passes a schema to SEOHead. The script waits for script[data-seo-schema]; a page without one times out.
  3. window.__PRERENDER__ is the build-time flag. The script sets it before navigation. Anything client-only checks it: the consent banner renders nothing, the analytics/GTM loader loads nothing (otherwise every deploy sends a phantom pageview), and intro/scroll animations are skipped (otherwise text is captured hidden). MUST_NOT_CONTAIN proves the banner stayed out: use the banner's own markup (data-testid="consent-banner") and a phrase only it uses. Not a generic phrase like "analytics cookies": the prerendered cookie and privacy policies contain it.
  4. Root-relative URLs. Vite injects modulepreload links with the prerender server's absolute URL; the script rewrites http://localhost:PORT/ to / or they 404 in production.
  5. Content fetched at runtime must be in the build upload. E.g. legal pages as public/legal/*.md: a .gcloudignore with *.md drops them at any depth, so add !public/legal/*.md. Rule 1's gate is what catches this.
  6. /login and /register are not prerendered: no indexable content, and they would compete with / for the brand name. Token pages and signed-in pages go in robots.txt Disallow, not in the routes list.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.