| Crates.io | hauchiwa |
| lib.rs | hauchiwa |
| version | 0.10.0 |
| created_at | 2024-07-20 15:25:03.618163+00 |
| updated_at | 2026-01-24 15:25:02.676093+00 |
| description | Flexible static website generator library with incremental rebuilds and cached image optimization |
| homepage | |
| repository | https://github.com/kamoshi/hauchiwa |
| max_upload_size | |
| id | 1309544 |
| size | 233,100 |
A flexible, incremental, graph-based static site generator library for Rust. It provides the building blocks to create your own custom static site generator tailored exactly to your needs.
Unlike traditional SSGs that force a specific directory structure or build pipeline, Hauchiwa gives you a task graph. You define the inputs (files, data), the transformations (markdown parsing, image optimization, SCSS compilation), and the dependencies between them. Hauchiwa handles the parallel execution, caching, and incremental rebuilds.
If you are tired of:
Then Hauchiwa is for you.
image and caching.grass.esbuild.deno and esbuild.Blueprint into a proper static website.Add hauchiwa to your Cargo.toml:
[dependencies]
# Check crates.io for the latest version
hauchiwa = "*"
# Serde is needed to parse frontmatter
serde = { version = "1", features = ["derive"] }
Create your generator in src/main.rs:
use hauchiwa::{Blueprint, Website, Output};
use serde::Deserialize;
// 1. Define your content structure (Frontmatter)
#[derive(Deserialize, Clone)]
struct Post {
title: String,
}
fn main() -> anyhow::Result<()> {
// 2. Create the configuration
// We explicitly specify the global data type as `()`
// since we don't have any global state yet.
let mut config = Blueprint::<()>::new();
// 3. Add a loader to glob markdown files
// `posts` is a Handle<Assets<Document<Post>>>
let posts = config.load_documents::<Post>("content/**/*.md")?;
// 4. Define a task to render pages
// We declare that this task depends on `posts`.
hauchiwa::task!(config, |ctx, posts| {
let mut pages = Vec::new();
// Iterate over loaded posts
for post in posts.values() {
let html_content = format!("<h1>{}</h1>", post.metadata.title);
// Create a page structure
// Output::html creates pretty URLs (e.g., /foo/index.html)
pages.push(Output::html(&post.path, html_content));
}
Ok(pages)
});
// 5. Build the website
let mut website = config.finish();
website.build(())?;
Ok(())
}
By default, Hauchiwa is built with the following features, but you can opt out
of them by disabling them in your Cargo.toml file, if you don't need them.
grass: Enables SCSS/Sass compilation.image: Enables image optimization (WebP, resizing).tokio: Enables the Tokio runtime for async tasks.live: Enables live-reload during development.server: Enables the built-in development server.The best place to learn is the API Documentation. It covers the core concepts in depth.
GPL-2.0 or later.