Python API
Zorto’s Python API lets you load, inspect, and build sites programmatically. Install the package:
uv add zorto
The Python package includes the same Rust engine compiled as a native extension — there is no performance difference from the CLI.
Quick start #
import zorto # Load a site — returns a Site object site = zorto.load(root=".") # Site # Access site data print(site.config.title) # Config for page in site.pages: # list[Page] print(page.title, page.permalink) # Build the site zorto.build(root=".")
CLI from Python #
You can also invoke the full CLI from Python:
import zorto zorto.run_cli(["build"]) # same as `zorto build` zorto.run_cli(["preview", "--open"]) # same as `zorto preview --open`
API reference #
zorto.build(root='.', output_dir=None)
Build a Zorto site from the given root directory.
zorto.load(root='.')
Load a Zorto site from the given root directory.
type(zorto.load("website")).__name__
Error: cannot read website/config.toml: No such file or directory (os error 2)
zorto.run_cli(argv: list[str] | None = None) -> None
Run the zorto CLI with the given arguments.
zorto.version()
Return the zorto version string.
zorto.version()
'0.21.0'
class zorto.Config()
Zorto site configuration.
class zorto.Page()
A content page.
class zorto.Section()
A content section.
class zorto.Site()
A loaded Zorto site.