(sigil publish)
(sigil publish) - Static Site Generation Library
A composable pipeline for generating websites from various content formats. Library-first design with functions and dicts.
Quick Start
(import (sigil publish))
;; Build a site
(let ((my-site (site title: "My Site"
content: "content/**/*.md")))
(execute-graph (build-graph (my-site config:) (my-site pipeline:))))Architecture
Two-phase execution for memory efficiency:
- Build Graph: Scan sources, create items with producers
- Execute: Call producers to render content
For incremental rebuilds, use execute-changed instead of execute-graph.
Exports
siteprocedureCreate a site configuration.
Returns a dict with:
- config: Configuration dict for the pipeline
- pipeline: List of pipeline stages
- watch-patterns: List of glob patterns to watch for changes
The pipeline: argument can be:
- A list: Use as the complete pipeline (replaces default)
- A procedure: Called with default pipeline, returns modified pipeline
- Omitted: Use auto-generated pipeline from content/assets
;; Simple site with defaults
(site title: "My Blog"
content: "posts/**/*.md"
assets: "static/**/*")
;; Custom pipeline (complete override)
(site title: "My Site"
output-dir: "public"
pipeline: (list (scan-files "docs/**/*.md")
filter-drafts
build-navigation
attach-content-producers))
;; Modify default pipeline
(site title: "My Docs"
content: "docs/**/*.md"
pipeline: (lambda (stages)
(append stages (list generate-docs-css))))run-publishprocedureRun a publish script with build/watch/serve commands.
Parses command-line arguments and executes the appropriate action:
- build: One-shot site generation
- watch: Rebuild on file changes (no server)
- serve: HTTP server + watch + live reload
Usage in scripts:
(import (sigil publish))
(define my-site
(site title: "My Site" ...))
(run-publish my-site)Then run: sigil site.sgl build or sigil site.sgl serve
build-graphprocedureBuild a publishing graph without executing producers.
Takes a config dict and a list of pipeline stage functions. Each stage has signature (config state) -> state. Returns the final state (graph) after all stages complete.
The graph can then be executed with execute-graph for a full build, or execute-changed for incremental rebuilds.
(define graph
(build-graph
#{base-url: "https://example.com"
output-dir: "out"}
(list
(scan-files "posts/**/*.md")
filter-drafts
build-navigation
attach-content-producers)))
(execute-graph graph) ; Full buildRe-exported from (sigil publish core)
execute-graphprocedureExecute all producers in a graph.
Calls each item's producer: thunk (if present) and each asset's producer: thunk (if present). Returns the graph with rendered: updated to list written paths.
(execute-graph (build-graph config pipeline))Re-exported from (sigil publish core)
execute-changedprocedureExecute only producers for items that changed.
Compares the new graph against the previous graph to find items with changed dependencies, then executes only those producers.
;; In watch loop:
(let ((new-graph (build-graph config pipeline)))
(execute-changed new-graph prev-graph))Re-exported from (sigil publish core)
scan-filesvariableRe-exported from (sigil publish scan)
scan-assetsvariableRe-exported from (sigil publish scan)
filter-draftsprocedurePipeline stage that removes draft items.
Checks config options: draft-mode: - if true, keeps drafts. Otherwise, removes items where metadata draft: is true.
Re-exported from (sigil publish stages)
build-ref-indexprocedurePipeline stage that builds cross-reference index.
Items with ref-id: metadata are added to the index. Key format: namespace:id or just id if no namespace.
Re-exported from (sigil publish stages)
build-path-indexprocedurePipeline stage that builds source-path to URL index.
This enables link rewriting by mapping source file paths to their canonical URLs. Cleans up /index.html to / for nice URLs.
Re-exported from (sigil publish stages)
attach-content-producersprocedurePipeline stage that attaches producers to content items.
For each item, attaches:
- producer: A thunk that renders the item when called
- dependencies: List of files this item depends on
The producer thunk:
- Loads body via body-loader
- Applies transforms (if configured)
- Applies theme to wrap in page structure
- Writes to output directory
- Returns the output path
Re-exported from (sigil publish render)
attach-asset-producersprocedurePipeline stage that attaches producers to assets.
For each asset, attaches a producer thunk that copies the asset file when called.
Re-exported from (sigil publish render)
rewrite-linksprocedureTransform that rewrites .md links to their output paths.
Use with config transforms: to automatically fix internal links. Resolves relative links against the current item's source path and looks up the target's output path in the path index.
Transform signature: (config state item node) -> node
Re-exported from (sigil publish stages)
resolve-refsprocedureTransform that resolves ref: links to content references.
Looks up ref:key or ref:namespace:id links in the ref-index and rewrites them to the target URL. Emits warnings to stderr for unresolved references.
If link text is empty, auto-fills from the reference title.
Transform signature: (config state item node) -> node
;; In markdown:
;; [First Post](ref:blog:first-post) -> link to blog post
;; [](ref:blog:first-post) -> auto-titled linkRe-exported from (sigil publish stages)
collection-pagevariableRe-exported from (sigil publish generate)
sxml-pagevariableRe-exported from (sigil publish generate)
default-themeprocedureDefault minimal theme.
Creates a simple HTML page with the content.
Re-exported from (sigil publish render)
sxml->htmlvariableRe-exported from (sigil publish render)
syntax-highlightprocedureHighlight Scheme/Sigil code blocks.
Handles two formats:
- (pre (@ (lang "scheme")) ...) from markdown
- (pre (code (@ (class "language-scheme")) ...)) standard HTML
Tokenizes the code and wraps tokens in spans with CSS classes like tok-comment, tok-string, tok-keyword, etc.
Transform signature: (config state item node) -> node
Re-exported from (sigil publish transform)
state-itemsvariableRe-exported from (sigil publish core)
state-assetsvariableRe-exported from (sigil publish core)
state-ref-indexvariableRe-exported from (sigil publish core)
state-path-indexvariableRe-exported from (sigil publish core)
docs-themeprocedureDocumentation site theme matching the Sigil docs design.
Uses external CSS at /css/style.css with dark theme and sidebar navigation. This theme is designed for the Sigil documentation site and matches the existing site styling.
Re-exported from (sigil publish docs)
generate-docs-cssprocedurePipeline stage that generates the docs CSS file.
Adds a synthetic asset with a producer that writes /css/style.css during graph execution. This ensures CSS generation logging appears with other asset outputs.
Re-exported from (sigil publish docs)
scan-api-docsprocedureCreate a pipeline stage that scans API documentation.
Scans compiled .sgb files from a lib directory and extracts documentation via runtime introspection. Procedure docstrings are available at runtime; module-level descriptions require compiler support (see %set-module-docstring!).
Options: output-prefix: - URL prefix for generated pages (default: "/lib/") filter: - Predicate (path-string) -> bool to filter modules Path is relative to lib-dir without .sgb extension (e.g., "sigil/core", "scheme/base") packages-dir: - Directory containing package sources (e.g., "packages") If provided, modules are grouped by package on the index
(scan-api-docs "build/lib"
output-prefix: "/lib/"
packages-dir: "packages"
filter: (lambda (path)
(or (string-starts-with? path "sigil/")
(string-starts-with? path "scheme/"))))Re-exported from (sigil publish docs)
scan-library-docsprocedureScan library documentation organized by package.
Creates a "Libraries" nav group with one entry per package. Each package page includes:
- Quick Reference section linking to .md docs from _pkg/
- Modules section listing API documentation
Example:
(scan-library-docs "build/dev/lib"
output-prefix: "/docs/lib/"
filter: (lambda (path)
(or (string-starts-with? path "sigil/")
(string-starts-with? path "scheme/"))))Re-exported from (sigil publish docs)
lib-index-templateprocedureTemplate for library index page body.
Returns SXML for the body content (without html/head wrapper). The pipeline's theme will wrap this in a full page. Groups modules by inferred package name.
Re-exported from (sigil publish docs)
module-details-templateprocedureTemplate for module documentation page body.
Returns SXML for the body content.
Re-exported from (sigil publish docs)
export-details->sxmlprocedureConvert export-details to SXML (export card structure). Uses the same card-based layout as the original site.
Re-exported from (sigil publish docs)
syntax-details->sxmlprocedureConvert syntax-details to SXML (export card structure).
Re-exported from (sigil publish docs)
format-library-nameprocedureFormat library name as (lib name).
Re-exported from (sigil publish docs)
module-details->output-pathprocedureConvert module-details to output path. Uses pretty URLs: /api/sigil-core/index.html
Re-exported from (sigil publish docs)