sigildocs

(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:

  1. Build Graph: Scan sources, create items with producers
  2. Execute: Call producers to render content

For incremental rebuilds, use execute-changed instead of execute-graph.

Exports

siteprocedure

Create 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-publishprocedure

Run 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-graphprocedure

Build 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 build

Re-exported from (sigil publish core)

execute-graphprocedure

Execute 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 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-filesvariable

Re-exported from (sigil publish scan)

scan-assetsvariable

Re-exported from (sigil publish scan)

filter-draftsprocedure

Pipeline 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)

Pipeline stage that builds navigation from item metadata.

Groups items by nav-group: metadata, sorts by nav-order:. Sets state navigation: to a dict with:

  • top-level: list of top-level nav items (no nav-group)
  • sections: list of nav group dicts

Re-exported from (sigil publish stages)

Pipeline 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)

Pipeline 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)

Pipeline 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:

  1. Loads body via body-loader
  2. Applies transforms (if configured)
  3. Applies theme to wrap in page structure
  4. Writes to output directory
  5. Returns the output path

Re-exported from (sigil publish render)

Pipeline 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)

resolve-refsprocedure

Transform 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 link

Re-exported from (sigil publish stages)

sxml-pagevariable

Re-exported from (sigil publish generate)

default-themeprocedure

Default minimal theme.

Creates a simple HTML page with the content.

Re-exported from (sigil publish render)

sxml->htmlvariable

Re-exported from (sigil publish render)

Highlight 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-itemsvariable

Re-exported from (sigil publish core)

state-assetsvariable

Re-exported from (sigil publish core)

Re-exported from (sigil publish core)

Re-exported from (sigil publish core)

Re-exported from (sigil publish core)

docs-themeprocedure

Documentation 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)

Pipeline 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-docsprocedure

Create 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 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)

Template 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)

Template for module documentation page body.

Returns SXML for the body content.

Re-exported from (sigil publish docs)

Convert export-details to SXML (export card structure). Uses the same card-based layout as the original site.

Re-exported from (sigil publish docs)

Convert syntax-details to SXML (export card structure).

Re-exported from (sigil publish docs)

Format library name as (lib name).

Re-exported from (sigil publish docs)

Convert module-details to output path. Uses pretty URLs: /api/sigil-core/index.html

Re-exported from (sigil publish docs)