Deployment¶
Astris can be deployed to Cloudflare Pages in two ways:
- Deploy from your local machine with
astris deploy. - Connect your Git repository in Cloudflare Pages and let Cloudflare build on each push.
1) Configure your project¶
Create or update pyproject.toml with Astris settings:
[tool.astris.build]
output_dir = "dist"
clean_urls = true
[tool.astris.deploy]
provider = "cloudflare"
[tool.astris.deploy.cloudflare]
project_name = "your-cloudflare-pages-project"
# branch = "main" # optional
[tool.astris.env]
# Add runtime variables used while building pages.
# DATABASE_URL = "postgresql://..."
What these options do¶
clean_urls = truegenerates pages aspath/index.htmland rewrites internal links as/path.output_diris the folder uploaded to Cloudflare Pages.tool.astris.envvariables are injected intoos.environbeforebuildanddeploy.
2) Deploy with astris deploy¶
Requirements:
- Python environment with Astris installed.
- Node.js installed (
npxmust be available). - Cloudflare authentication configured for Wrangler (
npx wrangler login).
Run:
uv sync
uv run astris deploy --file main.py
This command will:
- Load
[tool.astris]configuration frompyproject.toml. - Build your site using configured build options.
- Run Wrangler under the hood:
npx wrangler pages deploy dist --project-name your-cloudflare-pages-project
3) Deploy from Git (Cloudflare-managed builds)¶
If you prefer automatic deploys from your repository:
- In Cloudflare Dashboard, go to Workers & Pages > Create > Pages.
- Connect your Git provider and select the repository.
- Set build configuration:
- Build command:
uv run astris build --file main.py - Build output directory:
dist - In Cloudflare project settings, add any required environment variables.
- Trigger the first deploy.
Notes for clean URLs¶
With clean_urls = true, Astris generates files in folder-based format (about/index.html) and your links stay extensionless (/about). Cloudflare Pages serves these as clean routes.