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 surface #

The Python package exposes a small wrapper around the Rust engine:

NameKindPurpose
build(root=".")FunctionBuild a site from Python.
load(root=".")FunctionLoad a site and inspect its config, sections, and pages.
run_cli(argv=None)FunctionRun the Zorto CLI from Python.
version()FunctionReturn the installed Zorto version.
ConfigClassSite configuration.
SiteClassLoaded site model.
PageClassRenderable content page.
SectionClassContent section with child pages.