A lightweight static-site generator using Python + Jinja2
Version: 3.1.6dev
Engrave turns a directory of HTML templates (plus optional Markdown snippets) into a ready-to-serve static site. It is ideal for documentation, simple marketing pages, or any static content that benefits from Jinja2 templating without adding a backend.
- Renders
.htmltemplates with Jinja2; path segments starting with_are ignored for HTML builds. - Built-in Markdown helpers: include Markdown files via
markdown('path.md')and render inline strings with the|markdownfilter. - Regex-driven asset copying (
--copy) and exclusion rules (--exclude) applied to both renders and copies. - Live preview server powered by FastAPI + Uvicorn with watchfiles + SSE for instant reload hooks.
- Simple Cyclopts-based CLI; works on Python 3.10+.
pip install engraveRender templates and copy assets from a source directory into an output directory.
engrave build -h
Usage: engrave build [ARGS] [OPTIONS]
Build static HTML files from templates.
╭─ Parameters ───────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ * --dir-src Source directory containing input files [required] │
│ * --dir-dest Destination directory for build output [required] │
│ --copy --empty-copy Path RegEx copy verbatim [default: []] │
│ --exclude --empty-exclude Path RegEx to exclude from processing [default: []] │
│ --log-level [choices: CRITICAL, FATAL, ERROR, WARNING, WARN, INFO, DEBUG, NOTSET] [default: INFO] │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯Run an initial build, start FastAPI/Uvicorn, and stream file-change events for live reload.
engrave server -h
Usage: engrave server [ARGS] [OPTIONS]
Start a development server with live preview.
╭─ Parameters ───────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ * --dir-src Source directory containing input files [required] │
│ * --dir-dest Destination directory for build output [required] │
│ --copy --empty-copy Path RegEx copy verbatim [default: []] │
│ --exclude --empty-exclude Path RegEx to exclude from processing [default: []] │
│ --host Host interface to bind the development server [default: 127.0.0.1] │
│ --port Port number for the development server [default: 8000] │
│ --watch --empty-watch Path RegEx to watch for changes and emit SSE [default: []] │
│ --sse-url SSE URL (Server Side Event) to emite watch event [default: __engrave/watch] │
│ --log-level [choices: CRITICAL, FATAL, ERROR, WARNING, WARN, INFO, DEBUG, NOTSET] [default: INFO] │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯- Serves rendered
.htmldirectly fromDIR_SRCand other assets fromDIR_DEST. - Watches
DIR_SRCfor.html/.mdchanges, applies the same copy/exclude rules asbuild, and mirrors deletions. --watchaccepts additional regex patterns (relative to the current working directory) whose changes are forwarded to clients astype='watch'.- Add a reload hook in your page:
const source = new EventSource('/__engrave/watch');
source.addEventListener('change', () => window.location.reload());markdown('path.md')loads a Markdown file relative to the current template (stays inside configured template roots).{{ content | markdown }}converts inline Markdown strings.- Markdown rendering uses Mistune by default and caches results by file mtime; you can supply a custom parser via
get_template(..., markdown_to_html=...)if embedding Engrave programmatically. - Multiple template roots are supported by passing a list to
dir_src.
python -m unittestMIT — see LICENSE.