web dev//rendering//SSG

SSG (static site generation) is a rendering strategy in which every page's HTML is produced once, at build time, and then served as plain files, so no server has to assemble anything when a reader arrives. It suits documentation, blogs, portfolios and any site whose content changes only when the author publishes.


SSG (static site generation) is a rendering strategy in which every page's HTML is produced once, at build time, and then served as plain files, so no server has to assemble anything when a reader arrives. It suits documentation, blogs, portfolios and any site whose content changes only when the author publishes.

The picture is a kitchen that cooks every dish before the restaurant opens: the HTML is already cooked, and serving is handing over a plate. A build step reads the content (Markdown, a CMS, a database), runs the templates and writes one HTML file per URL, which a CDN can then cache at its edge nodes around the world.

1Content and templatesat build time2The build writes every page's HTML3A CDN serves the filesno server work per visit

It is the fastest and cheapest point of the rendering spectrum. A request costs a file read, there is no server to crash or patch, and every crawler reads the full content in the first response, since the HTML already carries the text.

Its limit is freshness. Content changes only when the site is rebuilt, so a price that moves every minute or a page per logged-in user does not fit; frameworks answer with incremental regeneration of single pages, or by mixing static pages with SSR ones in the same site.

Static does not mean inert. The pages can still load JavaScript and hydrate interactive parts in the browser; Astro builds static pages by default and hydrates only the islands that need it.

SSG moves the cost of rendering from every visit to every publish.

When the content changes far less often than it is read, that trade wins by orders of magnitude.

SSG is often confused with SSR: both deliver HTML with the content inside, but SSR builds it on each request and SSG once, ahead of time. This site is close to SSG in spirit (its content compiles to static files at build), though its pages are drawn in the browser.