SiteGen

Sitegen is a simple, flexible, and fast static site generator written in Go. It supports incremental builds, live reloading, and a powerful template system.
Features
- π Fast & Incremental: Builds only what's needed.
- π Live Reload: Built-in development server with changes detection.
- π¨ Templating: Flexible Go templates with custom functions.
- π Markdown: Write pages in
.md with automatic HTML conversion.
- π¦ Zero Dependency: Single binary, easy to install.
- π§ File Handlers: Custom build commands for specific file types (e.g. CSS, JS).
- π Public Sharing: Instantly share your dev server via a public URL (like ngrok, built-in).
Installation
Install via alt β a zero-config CLI distribution proxy for GitHub Releases:
# Install alt (one-time setup)
curl -fsSL https://raw.githubusercontent.com/altlimit/alt/main/scripts/install.sh | sh
# Install sitegen
alt install altlimit/sitegen
Windows (PowerShell)
# Install alt (one-time setup)
powershell -Command "iwr https://raw.githubusercontent.com/altlimit/alt/main/scripts/install.ps1 -useb | iex"
# Install sitegen
alt install altlimit/sitegen
Or download binaries directly from the Releases Page.
Quick Start
-
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
Usage
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: "/")
-share Enable public sharing via sitegen.dev
-share-auth <u:p> Basic auth for share ("user:pass")
-share-server <addr> Share relay server (default: "sitegen.dev:9443")
-help Show help
Template System
Sitegen uses Go's html/template with extra helper functions.
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. |
Page Variables
.<key>: Any variable defined in YAML frontmatter is accessible directly at the root (e.g., .title). When iterating over sources (e.g. range sources), use .Meta.<key> on the source item instead.
.Dev: Boolean, true if running in development mode.
.Source: Current source object (.Source.Meta has the raw frontmatter map).
.BasePath: Configured base path.
.Today: Current date (YYYY-MM-DD).
.Year: Current year (YYYY).
.Path: Current page path (if parameterized).
.Page, .Pages: Pagination info.
.BuildID: Unix timestamp string, regenerated on every build (useful for cache busting).
Basic Example
src/about.html:
---
title: About Us
template: main.html
---
{{define "content"}}
<h1>{{ .title }}</h1>
<p>Welcome to our site!</p>
{{end}}
File Handlers
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
---
*/
Public Sharing
Share your development server publicly with a single flag β no ngrok or third-party tunnels needed:
sitegen -serve -share
This creates a public URL like https://<id>.sitegen.dev that tunnels to your local dev server with hot reload support.
To require a password:
sitegen -serve -share -share-auth "admin:secret"
The share tunnel only serves static files from your public/ directory (GET/HEAD only) and reconnects automatically if the connection drops.
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
License
MIT