Orchestrates the full site build pipeline.
The builder runs through these stages:
- Resolve config — merge defaults, app env, and runtime options
- Discover — find all
.mdfiles in the content directory - Parse — parse front matter and render Markdown for each file
- Classify — determine content type from directory structure, enrich with type metadata
- Filter — exclude drafts (unless
drafts: true) - Validate — log warnings for missing required fields (e.g.,
dateon articles) - Enrich — add reading time, table of contents, and prev/next navigation to content metadata
- Render — apply three-layer template pipeline for individual pages
- Archives — generate tag and category archive pages
- Indexes — generate paginated content type index pages
- Feeds — generate Atom feeds (main + per-type)
- Sitemap — generate XML sitemap
Examples
# Build with defaults
{:ok, result} = Sayfa.Builder.build()
# Build with custom paths
{:ok, result} = Sayfa.Builder.build(content_dir: "my_content", output_dir: "custom_dist")
# Clean output directory
:ok = Sayfa.Builder.clean(output_dir: "custom_dist")
Summary
Functions
@spec build(keyword()) :: {:ok, Sayfa.Builder.Result.t()} | {:error, term()}
Builds the site from content files to HTML output.
Options
All options from Sayfa.Config.resolve/1 are accepted, plus:
:content_dir— source content directory (default:"content"):output_dir— output directory (default:"dist"):drafts— include draft content (default:false):fingerprint— enable asset fingerprinting (default:true; set tofalsein dev)
Examples
{:ok, %Sayfa.Builder.Result{files_written: 2}} = Sayfa.Builder.build()
@spec clean(keyword()) :: :ok
Removes the output directory.
Examples
:ok = Sayfa.Builder.clean(output_dir: "dist")