Static Site Generation (SSG)
SSG generates websites at build time as static files, optimizing load performance, security and simple delivery via CDNs.
Classification
- ComplexityMedium
- Impact areaTechnical
- Decision typeArchitectural
- Organizational maturityIntermediate
Technical context
Principles & goals
Use cases & scenarios
Compromises
- Static files can become stale if deploy processes fail
- Complexity from hybrid approaches (SSG + client hydration)
- Scaling builds can strain CI resources
- Keep content versioned in Git and make builds reproducible
- Optimize assets (images, CSS minification) in the build pipeline
- Define clear cache invalidation and deploy strategies
I/O & resources
- Content sources (Markdown, MDX, CMS export)
- Template engines and layouts
- Build tools and asset pipeline
- Static HTML, CSS and JS artifacts
- Sitemap, RSS feeds, asset manifests
- Deployable bundles for CDN/hosting
Description
Static Site Generation (SSG) is an architectural approach where pages are pre-rendered at build time into static HTML, CSS, and JavaScript assets. This yields fast, cacheable and low-attack-surface deployments without runtime server rendering. SSG is well suited for documentation, marketing sites and blogs with largely stable content.
✔Benefits
- High delivery performance via pre-rendered assets
- Reduced attack surface without server-side rendering
- Simple scalability and low-cost hosting
✖Limitations
- Limited support for highly personalized content
- Longer build times for very large sites
- Requires additional solutions for dynamic features (e.g., search, auth)
Trade-offs
Metrics
- Build time
Total duration of a full build; affects release speed and CI costs.
- Time to First Byte (TTFB)
Measure of perceived load performance when first accessing a page.
- Cache hit ratio
Proportion of requests served directly from CDN/cache.
Examples & implementations
Hugo documentation
Documentation of an open-source project using Hugo to produce fast static pages.
Jekyll on GitHub Pages
Publishing personal and project sites using Jekyll and GitHub Pages as hosting workflow.
Gatsby marketing site
Marketing website combining SSG for SEO and performance with client-side hydration for interactive components.
Implementation steps
Choose a suitable SSG tool (e.g., Hugo, Jekyll, Gatsby)
Set up templates, layouts and local build processes
Integrate into CI/CD, configure automated builds and deploys
Define and test CDN and cache strategy
⚠️ Technical debt & bottlenecks
Technical debt
- Monolithic build scripts without modularization
- Hardcoded CDN paths in templates
- Missing automation for cache invalidation
Known bottlenecks
Misuse examples
- Using SSG for highly personalized dashboard applications
- Relying on manual deploys due to build speed
- Omitting cache invalidation after page updates
Typical traps
- Not accounting for search index updates on content changes
- Missing strategy for private or protected content
- Underestimating build time as site grows
Required skills
Architectural drivers
Constraints
- • Real-time data requires additional APIs or functions
- • Large number of pages increases build and deploy effort
- • Dependency on external services for dynamic content