Skip to content
tezvyn:
Menu

Static Site Generation: Pre-built Pages for Speed & Simplicity

Source: Wikipedia: Static site generatorEasyHow cards are made

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.

Interview question

What is the fundamental difference in how Static Site Generation (SSG) delivers web content compared to a dynamic website?

  • a.SSG requires a powerful server to compile pages for every request, whereas dynamic sites use simple hosting.
  • b.SSG pre-builds all pages into static files during a build process, ready for instant delivery.Correct
  • c.SSG primarily uses server-side scripting languages to fetch data from a database for each page view.
  • d.SSG generates content in real-time based on user interactions, while dynamic sites use pre-built files.
Why?

The card explicitly states SSG "pre-builds every page... into static HTML files, instead of generating them on-demand," making them ready for instant delivery. Dynamic sites, by contrast, generate content on-demand for each request, which is the opposite of option D.

Just read this? Test yourself on what you have been reading.

Read the original → en.wikipedia.org

Put your scrolling time to good use

Learn one idea, try a quiz and save useful cards for revision. Tezvyn makes it easy to learn and stay current in your tech field, a few minutes at a time.

The iPhone app is on the way

We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.

Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.

Get it on Google PlayiPhone app coming soon

We are hiring for this. Every open role lists the topics its interview covers, so you can prepare for the real thing rather than guessing.

See open roles