No description
Find a file
2026-08-19 16:43:02 +02:00
app Adds a script tag to the head of the generated HTML through a flag 2026-08-19 16:43:02 +02:00
cli Adds a script tag to the head of the generated HTML through a flag 2026-08-19 16:43:02 +02:00
cmd/sarten Track CLI entrypoint and refine gitignore 2026-03-18 00:44:55 +01:00
discovery Add Phase 2 recipe discovery and parsing 2026-03-18 00:56:44 +01:00
fsx Implement build output pipeline and track implementation progress 2026-03-18 16:23:06 +01:00
logging Add verbose build reporting and expand rendered recipe sections 2026-03-18 16:34:22 +01:00
model Adds a script tag to the head of the generated HTML through a flag 2026-08-19 16:43:02 +02:00
parser Fix scaling for locked ingredient quantities 2026-03-20 22:16:30 +01:00
render Adds a script tag to the head of the generated HTML through a flag 2026-08-19 16:43:02 +02:00
serve Adds a script tag to the head of the generated HTML through a flag 2026-08-19 16:43:02 +02:00
site Add recipe reference links and shopping expansion 2026-03-25 11:24:26 +01:00
slug Add site assembly models and deterministic slugging 2026-03-18 15:11:12 +00:00
stitch_recipe_index(3)/stitch_recipe_index Add recipe reference links and shopping expansion 2026-03-25 11:24:26 +01:00
testdata Add fixture-driven MVP coverage and finalize progress docs 2026-03-18 16:50:34 +01:00
.gitignore Track CLI entrypoint and refine gitignore 2026-03-18 00:44:55 +01:00
generate_and_sync.sh Update deployment and planner import 2026-05-14 20:18:55 +02:00
go.mod Add Phase 2 recipe discovery and parsing 2026-03-18 00:56:44 +01:00
go.sum Add Phase 2 recipe discovery and parsing 2026-03-18 00:56:44 +01:00
justfile Add just build task for CLI binary 2026-03-18 00:58:02 +01:00
mise.toml Update deployment and planner import 2026-05-14 20:18:55 +02:00
README.md Adds a script tag to the head of the generated HTML through a flag 2026-08-19 16:43:02 +02:00
robots.txt Adds a script tag to the head of the generated HTML through a flag 2026-08-19 16:43:02 +02:00
spec.md Adds a script tag to the head of the generated HTML through a flag 2026-08-19 16:43:02 +02:00

Sarten

Sarten is a static site generator for Cooklang recipes, written in Go.

It scans a directory of .cook files, parses each recipe, and (as the project evolves) builds a static recipe website.

Current status

The MVP build pipeline is in place:

  • sarten build command and flags
  • recursive discovery of .cook files
  • Cooklang parsing and metadata mapping
  • deterministic slugging and site assembly
  • HTML rendering for index + recipe pages
  • embedded theme assets (templates and CSS) via Go embed
  • filesystem output writing to index.html, recipes/*.html, and assets/site.css
  • human-readable build summary output, plus verbose mode details
  • sarten serve for local preview with rebuild-on-request (no output directory required)

Prerequisites

  • Go 1.24.3 (or compatible with go.mod)
  • just (optional, for convenient task shortcuts)

Development setup

  1. Clone the repository.

  2. Install dependencies:

    go mod download
    
  3. Build the CLI binary:

    just build
    

    Or without just:

    go build -o ./bin/sarten ./cmd/sarten
    
  4. Run tests:

    just test
    

    Or:

    go test ./...
    

To refresh render golden files intentionally:

SARTEN_UPDATE_GOLDEN=1 go test ./render -run 'TestRenderMatchesGoldenFiles|TestRenderBaseURLMatchesGoldenFile'

Using Sarten

Build command

./bin/sarten build --input ./recipes --output ./public

Available flags:

  • --input (required): directory containing .cook files
  • --output (required): output directory for generated site files
  • --base-url: optional site base URL used to render absolute links in generated pages
  • --lang: language code for generated pages (en default, es available)
  • --site-title: optional site title for templates
  • --head-script: optional raw <script> tag inserted into the <head> of every generated HTML page
  • --clean: clean output before build
  • --verbose: enable richer logging

Serve command

./bin/sarten serve --input ./recipes --port 8080

Behavior:

  • serves generated pages directly from memory (no --output directory)
  • rebuilds by rereading .cook files on every HTTP request
  • supports --base-url, --site-title, and --head-script for generated links, titles, and custom head scripts

Available flags:

  • --input (required): directory containing .cook files
  • --host: host interface to bind the server (default 127.0.0.1)
  • --port: port to bind the server (default 8080)
  • --base-url: optional site base URL used to render absolute links
  • --lang: language code for generated pages (en default, es available)
  • --site-title: optional site title for templates
  • --head-script: optional raw <script> tag inserted into the <head> of every previewed HTML page
  • --verbose: enable richer request/build logging

For example:

./bin/sarten build --input ./recipes --output ./public \
  --head-script '<script defer src="https://example.com/analytics.js"></script>'

The tag is inserted as trusted, unescaped HTML. Only pass markup you control.

Canonical recipe example

The repository includes a canonical recipe fixture at testdata/canonical_recipe.cook.

It is used in tests and demonstrates most Cooklang capabilities and common metadata patterns:

  • frontmatter metadata (title, description, tags, servings, yield)
  • nested metadata blocks (source.name, source.author, time.prep, time.cook)
  • sections (== ... ==), inline comments (-- ...), and block notes (> ...)
  • ingredients, cookware, timers, and quantity/unit forms
  • relative ingredient reference (@./sauces/Hollandaise{...})

You can copy this file into your recipes directory to test full parsing behavior.

Additional fixture directories are available under testdata/fixtures/ for minimal, metadata, duplicate-title, full, and invalid scenarios used by end-to-end tests.

Static site output

The intended output layout is:

public/
  index.html
  assets/
    site.css
  recipes/
    <recipe-slug>.html

Build output semantics

  • Default build writes generated files into --output and leaves unrelated existing files untouched.
  • --clean removes the entire output directory before writing generated files.
  • If parsing fails, the build stops before writing output files, and existing output is left untouched.

Project structure

  • cmd/sarten: binary entrypoint
  • cli: command and flag parsing (kong)
  • app: build orchestration
  • discovery: .cook file scanning
  • parser: Cooklang parsing adapter
  • model: internal domain models

See spec.md for the full architecture and roadmap.