Package Version Hex Docs

A simple static site generator for Lustre projects, written in pure Gleam. lustre_ssg will run on both Gleam’s Erlang and JavaScript targets. If you’re using the JavaScript target, lustre_ssg is tested to work on both Node.js and Deno!

What it is

lustre_ssg is a low-config static site generator for simple things like a personal blog or documentation site. Declare your routes, tell lustre_ssg how to render them, and it will spit out a bunch of HTML files for you.

What it is not

lustre_ssg is not a batteries-included framework for generating static sites. There is no CLI, no built-in server, no fancy data fetching, and no client-side hydration. If you need those things, you will have to build them yourself!


  1. Add lustre_ssg as a development dependency to your Gleam project:
$ gleam add lustre_ssg --dev
  1. Create a build.gleam file in your project’s src directory.

  2. Import lustre/ssg and configure your routes:

import gleam/list
import gleam/map
import gleam/io

// Some data for your site
import app/data/posts

// Some functions for rendering pages
import app/page/index
import app/page/blog
import app/page/post

// Import the static site generator
import lustre/ssg

pub fn main() {
  let posts = map.from_list({
    use post <-
    #(, post)

  let build ="./priv")
    |> ssg.add_static_route("/", index.view())
    |> ssg.add_static_route("/blog", blog.view(posts.all()))
    |> ssg.add_dynamic_route("/blog", posts, post.view)

  case build {
    Ok(_) -> io.println("Build succeeded!")
    Error(e) -> {
      io.println("Build failed!")
  1. Run the build script to generate your static site!
$ gleam run -m build
$ tree priv

├── blog
│   ├── wibble.html
│   ├── wobble.html
│   └── ...
├── blog.html
└── index.html
Search Document