Skip to content

About

a small static site builder written in Rust

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

12 Commits

Folders and files

Repository files navigation

edowebbuild

edowebbuild is a small static site builder written in Rust. It renders HTML with Tera, copies static files and assets, and generates responsive image variants while preserving directory structures.

This project is currently under development.

Features

  • Tera templates, includes and components
  • JSON data as the global template context
  • TOML or YAML front matter in input files
  • Single-file and directory builds
  • Separate handling for static files and input assets
  • Incremental updates based on file modification times
  • Optional forced rebuilds with --force
  • Built-in development server with on-demand HTML rendering
  • Responsive JPEG, PNG, WebP and AVIF image variants
  • Automatic sitemap generation for directory builds

Requirements

  • Rust and Cargo
  • macOS or Linux when using the included installation target

Getting started

Rust with Cargo is required. Build and run the included example from the repository root:

cargo build
cargo run -- -c example/config.json

Alternatively, use the Makefile:

make run

The generated example is written to example/dist.

Configuration

By default, edowebbuild looks for an optional config.json in the current working directory. A different file can be selected with -c or --config.

{
  "title": "My site",
  "config": {
    "input": "content",
    "output": "dist",
    "template_dir": "templates",
    "static_dir": "static",
    "force": false,
    "devserver": false,
    "port": 3000,
    "icon_source": "assets/icon.png"
  }
}

Explicit command-line options override configuration values. Missing values fall back to dist, templates and static. The input must be provided either as a command-line argument or as config.input.

A missing configuration file is ignored. Other read errors and invalid JSON are returned to the command-line entry point and printed as errors. Set config.icon_source to generate the favicon and application icon set during a directory build; omit it or use an empty value to disable icon generation.

edowebbuild [OPTIONS] [INPUT]

Arguments:
  [INPUT]  Input file or directory

Options:
-o, --output <OUTPUT>
-c, --config <CONFIG>
-t, --templates <TEMPLATES>
-s, --static-dir <STATIC_DIR>
-f, --force
-d, --dev-server
-p, --port <PORT>
-h, --help
-V, --version

Templates and front matter

Input files are rendered as Tera templates. Per-file TOML or YAML front matter overrides values from the global JSON context.

+++
title = "Example page"
+++

{% extends "base.html" %}

{% block content %}
<h1>{{ title }}</h1>
{% endblock content %}

Each input template also receives base_dir, containing its parent directory, and file_name, containing its file name.

Responsive images

The image_srcset template function creates the src and srcset attributes. Build mode generates variants at 400, 800 and 1200 pixels wide by default and preserves image subdirectories.

<img
  {{ image_srcset(src="photo.jpg", width=800, base_dir=base_dir) }}
  sizes="100vw"
  alt="Example" />

Generated files follow the name-WIDTH.ext convention, such as photo-400.jpg. JPEG, PNG, WebP and AVIF are supported.

Sitemap

Full and incremental directory builds write sitemap.xml to the output root. Every HTML input file contributes one entry using its context after TOML or YAML front matter has been applied, unless its front matter sets noindex to true. Excluded pages are still rendered normally.

+++
title = "Not found"
noindex = true
+++

{% extends "base.html" %}

Set the global url value to the site's public base URL. A page can override its generated location with canonical, and can optionally provide changefreq and priority. The source file's modification time is used for lastmod. Files named index.html are represented as directory URLs.

Development server

Start the development server with the example configuration:

cargo run -- -c example/config.json --dev-server

The server listens on http://127.0.0.1:3000 by default. Select another port with --port:

cargo run -- -c example/config.json --dev-server --port 8080

HTML files are rendered from the input directory when requested. Non-HTML assets are served directly, while files from the static directory take priority. Directory requests resolve to their index.html file. GET and HEAD requests are supported. Paths containing parent-directory components are rejected with 400 Bad Request.

CSS remains unbundled and unminified in development. The browser loads native @import dependencies directly, so CSS optimization is only planned for production builds.

Missing image variants following the name-WIDTH.ext convention are generated from name.ext on demand. Supported formats are JPEG, PNG, WebP and AVIF.

The same example can be started through the Makefile:

make dev-server

Development

make check   # Format, lint and test
make build   # Create a release build
make clean   # Remove Cargo and example build output
make install # Install the release binary

make install defaults to /usr/local/bin on macOS and ~/.local/bin on Linux. Set INSTALL_PREFIX or INSTALL_DIR to override the destination.

ToDo

  • Exclude pages such as 404.html from sitemap.xml with noindex = true in their front matter.
  • SVG as icon input. Use resvg to render into a tiny_skia::Pixmap, then convert its RGBA pixel buffer into an image::RgbaImage or image::DynamicImage for the existing image pipeline. Note that tiny-skia stores premultiplied alpha values.
  • Integrate Lightning CSS for production CSS bundling and minification.
  • Integrate Rolldown for production JS/TS bundling, compilation and minification.
  • Development server should watch the template folder and reload templates when they change

License

Copyright (c) 2026 Benjamin Benno Falkner.

Licensed under the MIT License.

About

a small static site builder written in Rust

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages