Sitegen is a simple, flexible, and fast static site generator written in Go. It supports incremental builds, live reloading, and a powerful template system.
- 🚀 Fast & Incremental: Builds only what's needed.
- 🔄 Live Reload: Built-in development server with changes detection.
- 🎨 Templating: Flexible Go templates with custom functions.
- 📦 Zero Dependency: Single binary, easy to install.
- 🔧 File Handlers: Custom build commands for specific file types (e.g. CSS, JS).
curl -s -S -L https://raw.githubusercontent.com/altlimit/sitegen/master/install.sh | bashDownload the latest release from the Releases Page.
-
Create a new project:
mkdir my-website cd my-website sitegen -create -
Start development server:
sitegen -serve
Open http://localhost:8888 in your browser.
-
Build for production:
sitegen -clean -minify
sitegen [options]
Options:
-create Create a new site template
-site <path> Root site path (default: "./site")
-serve Start development server
-port <port> Port for development server (default: "8888")
-clean Clean public dir before build
-minify Minify HTML/JS/CSS output
-public <dir> Public output directory (default: "./public")
-base <path> Base URL path (default: "/")
-help Show helpSitegen uses Go's html/template with extra helper functions.
| Function | Description |
|---|---|
path |
Prefixes path with base URL. |
sources "prop" "pattern" |
Returns list of sources matching pattern. |
data "file.json" |
Loads JSON data from data/ directory. |
sort "prop" "order" |
Sorts input array/slice. |
limit n |
Limits the array/slice to n items. |
offset n |
Offsets the array/slice by n items. |
paginate n |
Paginates input. Populates .Page and .Pages. |
page "path" |
Creates a parameterized page from current source. |
.Dev: Boolean, true if running in development mode..Source: Current source object..BasePath: Configured base path..Today: Current date (YYYY-MM-DD)..Path: Current page path (if parameterized)..Page,.Pages: Pagination info.- Plus any variable defined in YAML frontmatter.
Customize how files are processed by adding a frontmatter block to any file (css, js, etc).
/*
---
serve: npm run build:css
build: npm run build:prod:css
---
*/Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.