Static Site Generation (SSG)
Static site generation renders routes into deployable HTML files before requests arrive, usually during a build or publishing process.
Download Markdown (.md)Soroush’s Product Wiki · https://wiki.soroush.uk/topic/static-site-generation/
01What it means
Static site generation (SSG), also called build-time rendering or prerendering in some systems, produces HTML and related assets ahead of user requests. A server or content delivery network can serve the resulting files without executing view logic for each visit. Static generation describes delivery timing, not whether pages contain JavaScript or later fetch dynamic data.[1][2]
- 01Discover routesChoose pages to generate
- 02Read build-time dataContent and dependencies
- 03RenderHTML and assets
- 04DeployStatic host or CDN
- 05RegenerateContent change or invalidation
Static generation describes when HTML is produced, not whether the page later runs JavaScript or fetches dynamic data.
02Why it matters
Prebuilt output can be fast, cacheable, inexpensive to serve, and operationally simple. The tradeoff shifts work and freshness concerns into build, invalidation, and deployment workflows.
03When to use it
Use SSG for documentation, marketing, editorial, catalogue, and other routes whose content can tolerate publishing latency. Use request-time or client rendering for highly personalized, permission-sensitive, or continuously changing views.
04How it works
- A build process discovers the routes that should exist.
- It reads content and data available at build time.
- Templates or components render each route to HTML and assets.
- The generated output is deployed to a static host or CDN.
- Content changes trigger rebuilds, selective regeneration, or cache invalidation.
05A practical example
A product documentation site generates thousands of versioned pages when approved content changes. A CDN serves the HTML globally, while a small client script adds search; urgent corrections trigger a targeted rebuild.
06Where it breaks
Large route sets can make builds slow, deployed content can become stale, and build-time access to sensitive data can leak it into public files. Personalized pages and unpredictable route combinations do not fit straightforward generation.
Common mistakes
- Calling a generated page noninteractive merely because its HTML is prebuilt.
- Embedding secrets or private records in public build output.
- Rebuilding every route for a small content change without measuring the cost.
- Ignoring freshness, rollback, and invalidation requirements.
07Sources
- Rendering on the Webweb.dev · Official technical guidanceRendering on the Web
- Pre-renderingNext.js · Official framework documentationPre-rendering