#build

    The build pipeline and its incremental cache.

    Import as justjavac/fus/build.

    make_options(root, config?, dest?, force, drafts, quiet) builds the options struct; build_site(options) runs the pipeline and returns BuildResult (pages, generated, assets, skipped, writes, warnings, elapsed_ms).

    The pipeline: scan sources → split front matter → render templates → Markdown → layout → collections and pagination → copy assets → write changed files → remove stale outputs → run the built-in generators (sitemap, rss, jsonfeed, robots, llms, minify).

    build_site_with(options, formats, contents, env?) takes registries, so a host can add a data format, page format or template engine without editing Fus.

    Themes: resolve_theme(config) decides between the theme compiled into the binary, a directory on disk and no theme; page_shell decides what wraps a page. Both the build and justjavac/fus/check call them, so the two can never disagree about whether a page has a shell.

    Caching: a manifest stores a global hash (config, theme, every page) and a hash per output. Unchanged outputs are skipped, and pages deleted from the source have their old files removed. Page carries src, dest, url, data, body, html, output, paginated and skip.

    BuildOptions

    pub struct BuildOptions {
    root : String
    config : String?
    dest : String?
    force : Bool
    drafts : Bool
    quiet : Bool
    }

    Inputs to a build invocation.

    Construct with make_options or default_options.

    BuildResult

    pub struct BuildResult {
    pages : Int
    generated : Int
    assets : Int
    skipped : Int
    writes : Int
    warnings : Array[String]
    elapsed_ms : Int64
    }

    Statistics returned by build_site.

    pages counts source pages plus generated pages, generated counts pagination pages, assets counts copied static files, skipped counts cache hits, writes counts files actually written and elapsed_ms is the total build time.

    Page

    pub struct Page {
    src : String
    dest : String
    url : String
    data :
    Json

    body : String
    html : String
    output : String
    paginated : Bool
    skip : Bool
    }

    One content page in the build pipeline.

    src is the source-relative path, dest the output-relative path and url the public URL. data holds merged front matter, body the raw body and html the rendered markup. paginated marks generated archive pages and skip excludes drafts.

    PageShell

    pub(all) enum PageShell {
    Document
    NoLayout
    Missing(String)
    Applied(String)
    }

    What wraps a page body.

    ThemeSource

    pub(all) enum ThemeSource {
    NoTheme
    DiskTheme(String)
    BuiltinTheme
    } derive(Eq)

    Where a site's theme comes from.

    bool_field

    fn bool_field(value :
    Json
    , key : StringView) -> Bool

    Read a boolean field, defaulting to false.

    build_collections

    fn build_collections(pages : Array[Page]) ->
    Json

    Derive all, named and tag collections from the page set.

    Pages that drive pagination are excluded, and a page with skipCollection: true opts out of every collection.

    build_site

    async fn build_site(options : BuildOptions) -> BuildResult

    Run the full build pipeline with the built-in formats and engines.

    build_site_with

    Run the build pipeline with explicit extension points.

    formats parses configuration, _data files and front matter, contents turns a templated body into HTML, and engine_env supplies the template engines (created from the configuration when omitted). Pass prepared registries to build a site that uses a custom data format, page format or template engine.

    builtin_assets

    fn builtin_assets() -> Array[(String, String)]

    Static assets of the built-in theme, as (file name, contents).

    builtin_layout

    fn builtin_layout(layout : StringView) -> Bool

    Whether the built-in theme provides layout, compiled.

    The build and check both answer "does this layout exist" through one function, so a name the build can render is never reported as missing.

    content_prefixes

    fn content_prefixes(cfg :
    Config
    ) -> Array[String]

    Directories that must never be scanned as content, relative to the content root.

    A configured directory that lives outside that root (the output folder of a site whose srcDir is a subdirectory, for instance) is dropped. It cannot match a scanned path anyway, and keeping its name would hide a content folder that happens to share it — content/public with dest: public.

    static is here because a site rooted at the site root keeps its asset folder next to its pages. Without it every static file was copied twice: once as content (/static/app.css) and once as an asset (/app.css).

    date_from_name

    fn date_from_name(name : StringView) -> String

    Extract an ISO date from a file name (2026-12-01-post.md).

    default_options

    fn default_options() -> BuildOptions

    Return options for building the current directory with defaults.

    The defaults are: root ., no config/dest override, cache enabled, drafts excluded and summary printed.

    is_document

    fn is_document(body : StringView) -> Bool

    Whether a body already is a whole HTML document.

    A page that opens with <!doctype> or <html> brought its own shell; wrapping it in base would nest two documents. Templates that emit a full page are common enough that the check is worth the two string comparisons.

    is_excluded

    fn is_excluded(path : StringView, cfg :
    Config
    , prefixes : Array[String]) -> Bool

    Check whether a path is ignored or inside an excluded prefix.

    is_page_file

    fn is_page_file(path : StringView, cfg :
    Config
    ) -> Bool

    Check whether a path has a configured page extension.

    list_field

    fn list_field(value :
    Json
    , key : StringView) -> Array[String]

    Read an array-of-strings field, defaulting to empty.

    make_options

    fn make_options(root : String, config : String?, dest : String?, force : Bool, drafts : Bool, quiet : Bool) -> BuildOptions

    Create build options from explicit values.

    Use this when embedding Fus in another tool. config and dest are optional overrides; force bypasses the incremental cache, drafts includes draft pages and quiet suppresses the build summary.

    make_pagination

    fn make_pagination(items : Array[
    Json
    ], number : Int, page_size : Int, total : Int, base_url : String, page_count : Int) ->
    Json

    Build the pagination object exposed to one page of a sliced collection.

    minify_html

    fn minify_html(input : StringView) -> String

    Remove redundant whitespace from generated HTML.

    Scans for < and copies whole runs instead of walking character by character: page text is UTF-16, so per-character scanning both costs a transition per character and can split a surrogate pair.

    page_shell

    fn page_shell(body : String, front :
    Json
    , cfg :
    Config
    , has_layout : (StringView) -> Bool, themed : Bool) -> PageShell

    Decide the shell for a page.

    One decision, used by the build and by the validator, so a page can never be reported as shellless by one and wrapped by the other. has_layout answers whether a layout name is registered; themed says whether a theme is in charge, which is what allows the base fallback.

    page_url

    fn page_url(cfg :
    Config
    , front :
    Json
    , rel : StringView) -> String

    The public URL of a source file, language prefix included.

    check resolves URLs through this too, so duplicate detection and the messages it prints agree with what a build would actually produce. Resolving from the raw path instead made default-language pages look like they lived under /en/.

    plugin_override

    fn plugin_override(name : StringView, ctx :
    Json
    , env :
    TemplateEnv
    ) -> String?

    Render a site's override for one generator, if it wrote one.

    The template is looked up by the plugin's name, so _includes/sitemap.jinja and _templates/robots.liquid both work and the extension picks the engine.

    read_manifest

    async fn read_manifest(cache_dir : String) ->
    Json

    Read the manifest from cache_dir, returning {} when absent or invalid.

    render_builtin

    fn render_builtin(layout : StringView, page :
    Json
    , body : String, slot : (StringView) -> String) -> (String, String)?

    Render a compiled layout, returning its HTML and the layout that wraps it.

    None means the name is not compiled and the caller should look for a file in _layouts instead. base returns "" as its parent: it is the shell.

    slot resolves one fragment of the shell (head, header, menu, footer, pagination): a file in the site wins, the compiled fragment is the fallback, and an empty string means "nothing here".
    fn resolve_permalink(cfg :
    Config
    , front :
    Json
    , no_ext : String) -> String

    Expand permalink placeholders into a final URL.

    Supported placeholders: :path, :slug, :collection, :title, :date, :year, :month, :day. A template of false or none skips the page.

    resolve_theme

    async fn resolve_theme(cfg :
    Config
    ) -> ThemeSource

    Pick the theme for a loaded configuration.

    A directory on disk always wins over the built-in theme of the same name, so theme: fus keeps working for a site that vendored and edited that theme.

    run_plugin

    async fn run_plugin(plugin : StringView, cfg :
    Config
    , pages : Array[Page], site_data :
    Json
    , env :
    TemplateEnv
    ) -> Array[String]

    Execute one built-in output plugin.

    Returns the output-relative files it wrote, so the caller can record them in the manifest and delete them again when the plugin is removed from the configuration. Unknown names write nothing.

    set_path

    fn set_path(root :
    Json
    , path : StringView, value :
    Json
    ) -> Unit

    Assign a value at a slash-separated path, creating objects along the way.

    Data files use this so _data/nav/links.yaml lands at data.nav.links.

    set_str

    fn set_str(value :
    Json
    , key : String, s : StringView) ->
    Json

    Set a string field on a JSON object.

    split_language

    fn split_language(path : StringView, cfg :
    Config
    ) -> (String, String)

    Split a source path into its language and the path inside that language.

    zh/about.md belongs to zh when zh is configured; every other path belongs to the default language and is returned unchanged. A site without an i18n block returns ("", path), so nothing changes for single-language sites.

    str_field

    fn str_field(value :
    Json
    , key : StringView, fallback : String) -> String

    Read a string field with a fallback.

    theme_path

    fn theme_path(source : ThemeSource) -> String

    The theme's absolute directory, or "" when there is no directory to read.

    theme_signature

    fn theme_signature() -> String

    Revision of the compiled theme, for the build cache key.

    theme_slot

    fn theme_slot(name : StringView, page :
    Json
    , env :
    TemplateEnv
    ) -> String

    Resolve one shell slot, preferring the site over the compiled fragment.

    head has no compiled default: it is the injection point for extra <meta>, fonts or analytics, and renders nothing until the site provides it.

    url_to_dest

    fn url_to_dest(url : StringView) -> String

    Translate a site URL into an output-relative file path.

    write_manifest

    async fn write_manifest(cache_dir : String, global_hash : String, files : Map[String,
    Json
    ]) -> Unit

    Write the manifest, creating the directory when needed.

    version guards future format changes and global hashes every shared input (config, layouts, includes, data) so a change invalidates all pages at once.