🔥 All-Access Pass — $199 USD (Regular $499) · Unlock all 2,836 Astro themes ➔
komal.nakrani
Get All-Access Pass ($199)
ThemesCategoriesDocsBlogTips & TricksPricingGet All-Access Pass ($199)
Astro Fundamentals••By Komal Nakrani

What Is a Static Site Generator? A Plain Explanation

What a static site generator is, how it turns content and templates into HTML at build time, its pros and limits, popular options, and where Astro fits among them.

#Astro#Static Site Generator#SSG#Web Development

A static site generator (SSG) is a build tool that turns your content (Markdown, data files, CMS entries) and templates into finished HTML, CSS and JavaScript files before anyone visits the site. You run one build command, it writes a folder of plain files, and any web server or CDN can host that folder. Nothing is generated per request, so pages load fast, cost little to host, and have almost nothing to hack.

This explainer covers how a static site generator works, what it’s good and bad at, how the popular SSGs differ, and where Astro sits in that picture.

Key Takeaways

  • An SSG renders every page at build time; the server only hands out finished files.
  • Static sites are fast, cheap or free to host, and have a tiny attack surface.
  • Content changes require a rebuild, which a CMS webhook or Git push can trigger automatically.
  • Popular SSGs include Astro, Hugo, Eleventy, Jekyll and Gatsby, each with a different template language and speed profile.
  • Astro is a static site generator by default that can also render selected pages on demand.

How a static site generator works

Every SSG follows the same pipeline:

  1. Read content. Markdown files with frontmatter, JSON or YAML data, or entries fetched from a CMS API.
  2. Apply templates. Layouts and components define the HTML structure: header, navigation, article body, footer.
  3. Generate routes. One HTML file per page, often from rules like “one page per blog post” or “one page per tag”.
  4. Process assets. Bundle and minify CSS and JavaScript, optimize images, add content hashes to file names.
  5. Write output. A folder (dist/, public/ or _site/ depending on the tool) containing the whole site.

In Astro, that’s npm run build. A blog post in src/content/blog/hello.md becomes dist/blog/hello/index.html:

---
# src/content/blog/hello.md
title: "Hello world"
pubDate: 2026-11-02
---

This post becomes a plain HTML file at build time.
---
// src/pages/blog/[id].astro
import { getCollection, render } from 'astro:content';

export async function getStaticPaths() {
  const posts = await getCollection('blog');
  return posts.map((post) => ({ params: { id: post.id }, props: { post } }));
}

const { post } = Astro.props;
const { Content } = await render(post);
---
<article>
  <h1>{post.data.title}</h1>
  <Content />
</article>

getStaticPaths() tells Astro which pages to build. After the build, the server has no idea Markdown or Astro was ever involved; it just serves index.html. The getStaticPaths guide explains this pattern in detail.

Static vs dynamic websites

The alternative to an SSG is a dynamic site, where a server builds each page when it’s requested: WordPress running PHP, a Node.js app rendering templates, or any framework in server-rendering mode.

Static site (SSG) Dynamic site
When HTML is built Once, at build time On every request (unless cached)
Hosting Any static host or CDN Server or serverless runtime
Typical cost Free to very low Server or function costs
Speed Files served from the nearest CDN edge Depends on server and database
Security surface No server code, no database to attack Server, plugins, database
Content updates Rebuild and redeploy Immediate
Personalization Client-side only Per request

“Static” describes how pages are delivered, not how they behave. A static site can still have search, forms, comments, animations and interactive components; they run in the browser or call external services.

Benefits of a static site generator

Performance. HTML is ready before the request arrives, so time to first byte is just network time to the nearest CDN edge. There’s no database query, no template rendering, no cold start.

Low hosting cost. Cloudflare Pages, Netlify, Vercel and GitHub Pages all host static sites on free tiers. Even large sites cost little, because serving files is cheap. The deploy guide compares the hosts.

Security. With no server code or database, there’s nothing to inject into and no plugins to patch. The attack surface is your host and your build pipeline.

Reliability. Files on a CDN rarely go down, and traffic spikes don’t need more servers.

Version control. Content and code live in Git, so every change is reviewable and reversible.

Readable by crawlers. Search engines and AI tools get complete HTML in the first response.

Limitations to know about

Rebuilds for changes. Fixing a typo means rebuilding and redeploying. With a Git-based workflow or a CMS webhook, this is automatic and usually takes a minute or two, but it isn’t instant.

Build time grows with size. A site with tens of thousands of pages can take a while to build. Tools differ a lot here: Hugo is known for very fast builds; JavaScript-based SSGs are slower per page but have improved, and Astro has added features like parallel prerendering and incremental content caching.

No per-request logic. Anything that depends on who the visitor is (logged-in state, cart contents, location) can’t be in the static HTML. You handle it in the browser, with a third-party service, or by rendering that part on a server.

Editors need a workflow. Non-technical editors won’t edit Markdown in Git. You add a CMS on top, either Git-based like Decap or API-based like Sanity; see what is a headless CMS.

SSG Language Templates Known for
Astro JavaScript/TypeScript .astro components, plus React, Vue, Svelte islands Zero JS by default, component model, content collections, optional server rendering
Hugo Go Go templates Very fast builds, single binary
Eleventy JavaScript Nunjucks, Liquid, Markdown, WebC and more Minimal and flexible, no client framework
Jekyll Ruby Liquid The original GitHub Pages generator, long history
Gatsby JavaScript React GraphQL data layer, React everywhere
Docusaurus, Starlight, VitePress JavaScript Framework-specific Documentation sites

Choosing between them usually comes down to the language your team knows, how much interactivity you need, and how big the site will get. The Astro vs Hugo and Astro vs Eleventy comparisons go deeper.

Where Astro fits as a static site generator

Astro is a static site generator by default. A new project has output: 'static', and astro build writes static HTML for every route. What sets it apart from older SSGs:

  • Components instead of template languages. .astro files look like HTML with a script block, and they compose like React components without shipping React to the browser.
  • Islands for interactivity. You can drop in a React, Vue, Svelte or Solid component and hydrate only that component. Everything else stays HTML. The islands architecture guide explains how.
  • Typed content. Content collections validate frontmatter with a schema, so a missing date fails the build instead of breaking a page.
  • Optional server rendering. Add an adapter and mark one route with export const prerender = false, and that route renders per request while the rest stays static. You don’t have to switch tools when one page needs a server.

That last point blurs the line between SSG and framework. Astro is best described as a static-first web framework: static unless you ask otherwise. The what is Astro page covers the full picture.

Do you need a static site generator?

An SSG is a strong fit for blogs, documentation, portfolios, marketing sites, landing pages, small business sites and product catalogs with infrequent changes. It’s a weak fit for apps where most content depends on the logged-in user, or where content changes every second.

If you want the benefits without building from scratch, a theme gives you the finished templates. Every Komal theme is a complete Astro project that builds to static files, so you can browse Astro themes by site type and deploy the output to any static host. For the official overview of what Astro builds, see Astro’s docs on rendering modes.

FAQ

What is a static site generator used for?

It’s used to build websites whose pages can be prepared ahead of time: blogs, documentation, portfolios, marketing and business sites. It turns content and templates into HTML files that are hosted on a CDN or static host.

Is Astro a static site generator?

Yes. Astro builds static HTML by default with astro build. It can also render selected routes on demand when you add an adapter, so it works as an SSG and as a server-rendered framework in the same project.

Can a static site have dynamic features?

Yes. Search, forms, comments, carts and interactive components can run in the browser or call external services. Only things that must be generated per request on the server, such as personalized pages, need server rendering.

Is a static site generator better than WordPress?

For speed, hosting cost and security, usually yes, because there’s no server or database to run. WordPress is easier for non-technical editors out of the box. Pairing an SSG with a headless CMS gives editors a similar experience.

Which static site generator is fastest?

Hugo is widely known for the fastest build times. For page load speed, all SSGs produce static files; the difference comes from how much JavaScript each sends to the browser, where Astro’s zero-JavaScript default helps.