Static Site Generation: Pre-built Pages for Speed & Simplicity
Static Site Generation (SSG) pre-builds every page of your site into static HTML files, instead of generating them on-demand. This makes sites incredibly fast and cheap to host on a CDN, perfect for blogs or docs. The footgun: build times grow with site size.
WHY IT EXISTS Dynamic websites must run complex code for every page view, which adds latency and requires powerful servers. SSG solves this for content that rarely changes by doing all the work upfront, resulting in a set of simple files that are fast, cheap, and secure to serve.
THE MENTAL MODEL Think of it as a bakery that pre-makes its most popular cakes instead of baking a new one for every customer. An SSG 'bakes' your entire website into static HTML files during a single build step. These finished 'cakes' are then placed on a global shelf (a CDN) ready for instant delivery. A dynamic site, by contrast, bakes a custom cake for every single order, which is much slower.
HOW IT WORKS A static site generator is a tool that takes your content (often in text files like Markdown) and layout templates, and outputs a complete website made of plain HTML, CSS, and JavaScript files. There is no database or complex server-side logic needed for a visitor to view the site. This output folder is your complete website, ready to be uploaded to any simple web host.
WHEN TO USE IT SSG is ideal for content that is the same for every user and changes infrequently. Use it for blogs, software documentation, marketing websites, and portfolios. Because the pages are pre-built, they load almost instantly from a CDN and have a smaller attack surface, making them more secure than dynamic sites.
WHEN NOT TO USE IT Avoid SSG for sites requiring real-time data or user-specific content, like a social media feed, an e-commerce shopping cart, or a personalized dashboard. The core limitation is that every content change, no matter how small, requires a full site rebuild and redeployment.
ONE CANONICAL EXAMPLE A company's documentation site. Engineers write documentation in Markdown files and commit them to a repository. A CI/CD pipeline automatically detects the change, runs a generator like Hugo or Next.js, and builds the new static files. These files are then pushed to a CDN, making the updated documentation live worldwide in minutes with no server maintenance required.
Read the original → en.wikipedia.org
Get five bites like this every day.
Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.