Websites & Hosting

Static Site Generators Explained

See how a generator turns text files and templates into a finished website, how to choose one and where it struggles.

Key takeaways

  • A generator moves the work of building pages from the moment of each visit to the moment you publish.
  • Content is usually written in Markdown with a short block of metadata, and templates supply the layout.
  • Output is plain files that can be hosted cheaply and moved easily.
  • Features needing a server, such as logins or form handling, require separate services.
  • Pick a generator by your content, your comfort with its language and its upkeep, more than by popularity.

A static site generator is a program that takes your content files and templates and produces a complete website of ready-made HTML, CSS and JavaScript. You run it once when something changes, then upload the output to any web server. Visitors get plain files, with no database or application assembling pages as they arrive.

It gives you the main convenience of a content management system, which is writing content once and reusing a layout, while keeping the speed and simplicity of static files.

The build

What happens during a build
1 Read content Load text files and their metadata. 2 Gather data Read settings, data files or an outside source. 3 Convert Turn Markdown into HTML. 4 Apply templates Wrap each page in a shared layout. 5 Create indexes Build lists, tag pages, feeds and a sitemap. 6 Write output Save finished files into one folder ready to publish. Read content Load text files and their metadata. 1 Gather data Read settings, data files or an outside source. 2 Convert Turn Markdown into HTML. 3 Apply templates Wrap each page in a shared layout. 4 Create indexes Build lists, tag pages, feeds and a sitemap. 5 Write output Save finished files into one folder ready to publish. 6

What goes in

A typical project looks something like this, though folder names differ between tools:

mysite/
  content/
    about.md
    posts/first-harvest.md
  templates/
    base.html
    post.html
  static/
    style.css
    images/
  config file
  public/        (generated output)

A content file is usually Markdown, a lightweight markup that stays readable as plain text, topped by front matter, a block of metadata:

---
title: First harvest
date: 2026-05-14
tags: [vegetables, spring]
---
The radishes came in early this year.

## What worked

- Sowing in short rows
- Watering in the morning

Markdown explained covers the syntax, and a Markdown to HTML converter shows what it turns into.

Templates

A template is HTML with placeholders and a little logic. A simplified example:

<article>
  <h1>{{ page.title }}</h1>
  <p>{{ page.date }}</p>
  {{ page.content }}
</article>

Template languages vary, and some generators use components written in JavaScript instead. Shared pieces such as the header and footer live in one place, so a menu change updates every page at the next build. Templates also loop over content, which is how a list of recent articles stays current without anyone editing it.

The main families

Generators are written in many languages. Well-known examples include Hugo (Go), Jekyll (Ruby), Eleventy and Astro (JavaScript), and several documentation tools written in Python or JavaScript. Some frameworks, such as Next.js and others, can produce static output as well as run on a server.

If you mainly want Look for
A blog or small site A simple generator with themes you like
Documentation A documentation-focused tool with search and versioning
A very large site Fast builds and incremental options
Interactive pieces within pages Component support that ships little script by default

Features and popularity shift, so check each project's documentation and recent activity before committing.

Compared with a database-driven CMS

Generator and traditional CMS
Static site generator Pages built before anyone visits Content kept in files and version control Little to attack on the server Editors need a build workflow Database-driven CMS Pages built on request, then often cached Content edited in a web dashboard Application and plugins need patching Changes appear as soon as saved VS Static site generator Pages built before anyone visits Content kept in files and version control Little to attack on the server Editors need a build workflow Database-driven CMS Pages built on request, then often cached Content edited in a web dashboard Application and plugins need patching Changes appear as soon as saved

Neither is better in general. The question is who writes, how often content changes and whether pages differ per visitor. What is a content management system? looks at the other side.

Local preview and publishing

Most generators include a development server that rebuilds when you save a file, so you can see changes at a local address. When satisfied, you run a build command and publish the output folder.

Many people automate the last part: push changes to a Git repository, and a hosting platform or a pipeline builds and deploys them. Git basics and deploying from laptop to live explain the pieces. Static site hosting covers where the files can go.

Version control gives you history for free. You can see what changed, who changed it and return to an earlier state.

Letting non-programmers edit

The weak spot is authoring for people who do not want to touch files or Git. Options include:

  • editing Markdown files directly in the repository host's web interface,
  • a Git-based editing interface that provides forms and saves commits behind the scenes, or
  • a headless CMS that triggers a build whenever content is published.

Each adds an account and a delay while the site rebuilds. Try it with a real editor before promising anyone it will be easy.

Things that need a server

Because the output is fixed at build time, anything that depends on the visitor or on live data needs another piece:

  • contact forms: a form service or a serverless function,
  • search: a client-side index or a hosted service,
  • comments: an embedded service,
  • accounts and payments: dedicated providers,
  • frequently changing data: fetched in the browser, or a scheduled rebuild.

A page that says "published 3 days ago" computed at build time will stay frozen until the next build. Calculate such things in the browser or print the date itself. The same applies to posts dated in the future: they will not appear on their day unless something triggers a build.

Keeping builds healthy

Generators depend on a runtime and packages, and those change. A site left alone for two years may no longer build on a new computer.

Protect yourself:

  1. Record the generator version and runtime version in the repository.
  2. Commit the dependency lock file where your tool uses one.
  3. Keep themes and plugins few, and know what each does.
  4. Update on a schedule, on a branch, and compare the output before publishing.
  5. Make sure the build fails loudly on broken input instead of publishing half a site.

Builds that use secrets, such as a token for fetching content, should read them from the platform's protected settings. Anything printed into the output is public.

When builds get slow

Hundreds of pages usually build quickly. Many thousands, with heavy image processing, can take much longer. Remedies include caching processed images between builds, using incremental builds where supported, splitting the site or rendering rarely visited pages on demand with a framework that offers it.

Measure before reorganizing. Image resizing is often the main cost, and moving it elsewhere may be enough.

Choosing a theme or starting plain

Most generators offer themes. A good theme gets you published quickly with sensible navigation, feeds and responsive layout. Before adopting one, check that it has been updated recently, that it works with your version of the generator, that its license permits your use and that it loads no scripts or fonts from places you did not expect.

Writing your own templates takes longer and leaves you understanding every line. A middle path is to start with a minimal theme and override one template at a time, keeping your changes separate from the theme's files so that updates remain possible.

What to check in the output

The build folder is your real website, so inspect it:

  • Every page has a unique title and a description.
  • Internal links resolve. Many tools or add-ons can check this during the build.
  • A sitemap and, for a blog, a feed are generated with your real domain, not a local address.
  • Draft content is excluded.
  • Images are resized and given alternative text.
  • An error page exists and your host is configured to use it.

Two settings cause many first-launch problems. The base URL tells the generator what address the site will live at. If it is wrong, styles and links may break once published, especially when the site sits in a subfolder. Environment settings can also differ between preview and production builds, so view the published site itself, not only the local one.

Bringing content from elsewhere

If you are leaving a database-driven system, import tools can often convert posts into Markdown with front matter. Expect cleanup: embedded galleries, shortcodes and forms rarely translate. Keep the old addresses by setting each page's output path, or generate a redirect list. Convert a few varied posts first and read the results closely before running the whole archive through.

A first build, step by step

Whatever tool you pick, the first session follows a similar pattern:

  1. Install the generator and its runtime from the official instructions.
  2. Run the command that creates a starter project.
  3. Start the development server and open the local address it prints.
  4. Edit one content file and watch the page refresh.
  5. Change the site name and address in the configuration file.
  6. Run the production build and look inside the output folder.
  7. Upload that folder to a test host and click through it on a phone.

If a step fails, read the first error message, not the last. Later messages are often consequences of the earliest one. A missing closing line in front matter or a misspelled template name accounts for many early failures.

Is it for you?

A generator is a good fit if you are comfortable editing text files, your content is mostly the same for everyone and you value speed, low cost and portability. It is a poor fit if editors need instant publishing from any phone with no learning, or if the site is really an application.

To try one, pick a tool whose installation instructions make sense to you, create the sample site, change one template and one content file, then publish the result to a free or inexpensive static host. If that evening felt manageable, the rest is repetition. If it felt like a chore, a hosted builder will serve you better, and there is no prize for choosing the harder route.

Written for 4Internet with AI writing tools and not reviewed line by line by a person. Check anything you rely on with the maker, provider or standard concerned. Report an error.

Keep reading

All 45 articles in Websites & Hosting →

Latest news on this topic