statica
Powered HTML
statica turns valid HTML into a static site: fragments, local JS funnels, collections, pagination, scoped components, and browser-ready CSS — then emits files.
Always lowercase statica.
Full reference: docs/guide.md · Man pages: docs/man/
Two cores
| Concept | Role |
|---|---|
| Funnel | Build-time local JS value literals via <script type="statica/data" src id> |
| Pages | Every **/index.html — folder path is the route (incl. [slug] / [page]) |
Flow: Funnel → Pages → static HTML
Install
Rust (crates.io):
Library API: depend on statica and call statica::build.
JavaScript (npm):
Same CLI binary as cargo install statica-cli. Optional platform packages — no postinstall scripts.
Homebrew:
Prebuilt macOS and Linux binaries from GitHub releases. See homebrew/README.md for tap setup.
# package.json scripts: "build": "statica build ."
From this repo (dev):
Quick start
&&
Prefer the installed binary (statica …) over cargo run.
CLI
statica [PATH] build (default)
statica build [PATH] build
statica serve [PATH] preview out_dir (axum + tower-http)
statica watch [PATH] watch + rebuild + serve
statica new <NAME> scaffold
statica -h / --help
statica -v / --version
Project location: PATH (default .) → resolve against process cwd → walk up for statica.toml → site root is that dir, or project / --project under it.
Nested config tables use compact SPECs (CLI wins over the file):
Man pages
Generated from clap on every cargo build -p statica-cli:
Config (statica.toml)
Optional. Missing file → defaults. See docs/guide.md for the full reference.
= "" # relative to this file; empty = here
= ".dist"
= "" # needed for sitemap / RSS
[]
= false
= true
= true
= true
[]
= false
= 50000
[[]]
= "blog/[page]"
= 10
= "published_at"
= true
= true
[]
= false
= 50
[]
= "0.0.0.0"
= 4321
[]
= false
= ["en"]
| Asset kind | Tool |
|---|---|
| CSS | lightningcss (nesting, modern syntax → browser-ready; minify with --process or --minify) |
| JS | oxc |
| HTML | minify-html (final pass with --minify) |
| Images | oxipng + image |
| Fonts | copied as-is |
Inline <style> (pages + fragments) is always transformed. Linked .css under asset_dirs is transformed when [process].css is on. Enable [minify] / --minify for a final pass on emitted HTML, CSS, and JS (including inline <style> / <script>).
Authoring
index.html → .dist/index.html
posts/[slug]/index.html → .dist/posts/{item.slug}/index.html
blog/[page]/index.html → .dist/blog/1/, blog/2/, … ([[pagination]])
- Content →
<slot name="field">(field must be declared in the fragmentdata-bind) - Attributes →
${field}(same — no magic vars; usedata-bind="{a, b}"or${prop.field}) - Collection:
<html data-bind="posts">ordata-bind="{…}">+[slug] - Pagination:
<html data-bind="{page, items, …}">+[page]
Crate layout
crates/statica-cli— CLI (cwd/project resolve, config, SPECs, watch/serve, man pages)crates/statica— discover → funnel → bind → scope → emitexamples/blog— dogfood fixturedocs/— guide + man pages
License
MIT