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
In this repository7 other files it gives its agents.
- deploy-cloudrunSkill
- gcp-bootstrapSkill
- gcp-migrate-dataSkill
- react-api-clientSkill
- react-app-scaffoldSkill
- react-auth-otpSkill
- stack-auditSkill
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
- Very specific: line 31
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 …
≈ “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.
Files
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/)
| File | Copy to | Role |
prerender.js | front-end/prerender.js | Serves 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.js | front-end/prerender.routes.js | The list of public routes to prerender — keep in sync with public routes in App.tsx |
SEOHead.tsx | src/components/seo/SEOHead.tsx | Per-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
npm i -D puppeteer serve-handler- package.json scripts:
"build:ssg": "tsc -b && vite build && node prerender.js" - Render
<SEOHead title=... description=... path=... schema={...} />at the top of every public page; prerender waits for these tags before capturing. - Docker: the frontend build stage needs Chromium — the deploy-cloudrun skill's
frontend.Dockerfilehas the marked block (PUPPETEER_EXECUTABLE_PATHetc.) and usesnpm run build:ssg. - When adding a public page: add the route to
prerender.routes.jsAND aMUST_CONTAINentry inprerender.js, or it won't be prerendered, gated or listed in the sitemap.
Rules (each one learned from a shipped bug)
- Gate every route. A prerender that captures an empty
#rootstill 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. - Every prerendered page passes a
schematoSEOHead. The script waits forscript[data-seo-schema]; a page without one times out. 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_CONTAINproves 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.- Root-relative URLs. Vite injects
modulepreloadlinks with the prerender server's absolute URL; the script rewriteshttp://localhost:PORT/to/or they 404 in production. - Content fetched at runtime must be in the build upload. E.g. legal pages as
public/legal/*.md: a.gcloudignorewith*.mddrops them at any depth, so add!public/legal/*.md. Rule 1's gate is what catches this. /loginand/registerare not prerendered: no indexable content, and they would compete with/for the brand name. Token pages and signed-in pages go inrobots.txtDisallow, not in the routes list.
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
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.

