Look up exact behavior
Site-building API
Reference for the main builder methods, context types, route metadata, artifacts, and asset requests.
Public API reference
This page summarizes the main API exposed by site-core.
Site builder
Site::builder() creates a SiteBuilder.
Main builder methods:
content_dir(...): choose the content root, defaulting tocontent/cache_dir(...): choose the incremental-build and asset-cache directorypage_route_output(...): choose whether page-like routes emit as.../index.htmlor...htmlcollection::<T>(key): load one typed collection fromcontent/<key>/validate_collection::<T, _>(key, validator): run semantic validation after all collections loadpage(path, handler): register one explicit page-like routefile(path, handler): register one explicit flat-file outputcollection_page::<T, _>(key, "/path/{slug}/", handler): register one route per content entrygenerated_routes(routes, handler): register a computed route familymarkdown_component(tag, component): override one markdown-generated HTML tagprocessor(processor): register a route artifact post-processorasset_processor(processor): register an asset post-processorbuild(): load content and return a renderableSite
Route shapes
Use:
page(...)for known page-like routes and extension-based files such as/sitemap.xmlfile(...)for explicit flat files such asrobots.txtor/_headerscollection_page(...)for the one-entry-one-route casegenerated_routes(...)when content decides which routes exist
PageRouteOutput controls whether page-like routes emit as directory indexes or flat .html files.
Context types
RenderContext:
reads collections
reads individual entries by slug or by
EntryRef<T>renders markdown
resolves authored assets, concrete image outputs, and responsive image outputs
probes authored images without decoding their full pixel payload
inspects
ctx.routes()
RouteSourceContext:
decides which generated routes exist
reads collections during route expansion
records dependencies for route-family invalidation
CollectionValidationContext:
validates frontmatter after collections load
resolves slug references during validation
creates source-aware diagnostics
Markdown component context
ComponentProps is passed into markdown component overrides registered through
markdown_component(tag, component).
It exposes:
tagattrschildrenattr(key)asset_url(key)image_url(key, output)responsive_image(key, output)probe_image(key)
That lets markdown component code stay close to the authored tag while still resolving local asset references through the same pipeline used by route handlers.
Route metadata
GeneratedRoute supports:
GeneratedRoute::new(path, data)GeneratedRoute::file(path, data)with_source_entry(collection, slug)with_attribute(key, value)
RouteInfo exposes:
pathsource_entriesattributesattribute(key)has_attribute(key, value)references_collection(key)references_entry(key, slug)
Pagination helper
paginate(...) splits owned items into numbered pages and returns PaginationPage<T> values with:
page_numbertotal_pagesitems
It is intentionally narrow. It removes the repeated bookkeeping without hiding route definitions behind a DSL.
Artifacts
Use:
Artifact::HtmlArtifact::XmlArtifact::JsonArtifact::Text
Artifact kind and output filename are independent. If you need a literal output path, use file(...) or GeneratedRoute::file(...).
Build results
Site::render_to(output_dir) returns a BuildReport.
BuildReport exposes:
routes: oneRouteBuildRecordper routeassets: oneAssetBuildRecordper generated public assetremoved_outputs: public outputs removed because they no longer belong to the route setemitted(): number of routes rendered during this buildskipped(): number of routes reused from the previous buildasset_operations(): number of public asset outputs materialized during this build
Route records carry:
route_pathoutput_pathstatus
Route status is either:
RouteBuildStatus::Emitted(BuildReason)RouteBuildStatus::Skipped
The current build reasons are:
NewRouteMissingOutputProgramChangedHandlerChangedOutputPathChangedDependencyChangedRouteManifestChanged
Asset records carry:
public_pathsource_pathstatus
Asset status is one of:
AssetBuildStatus::TransformedAssetBuildStatus::ReusedCachedObjectAssetBuildStatus::RestoredPublicCopy
This API is useful when a custom CLI, test, or deployment step needs to distinguish actual work from cache reuse.
Processors
Route processors implement ArtifactProcessor.
They receive:
the route path
the route
Artifact
Use them for output-level cleanup such as HTML minification or feed-specific rewriting. The built-in
IntertagWhitespaceMinifier is the current example.
Asset processors implement AssetProcessor.
They receive:
an
AssetProcessContextthe final output bytes from the asset pipeline
AssetProcessContext includes:
the authored source asset path
the source document when one exists
the original authored reference string
whether the output came from a copy or image-transform path
the final output extension when one exists
Override cache_key() when processor behavior depends on configuration that must invalidate cached
asset outputs.
Asset requests
The main image request types re-exported from site-core are:
ImageOutputResponsiveImageOutputImageFormatImageFitBackgroundColorImageProbeImageProbeFormat
Important behavior:
vector inputs stay vector by default
rasterize_vector_inputs()is explicit opt-inbackground flattening is part of the request
cache keys derive from source bytes plus a canonical transform description
the site-facing API stays agnostic to the source format
RenderContext::probe_image(...)andComponentProps::probe_image(...)can inspect authored image format and dimensions without a full image decode