Pagebake
Pagebake is a simple, modular static site generator library written in Rust. Inspired by Axum, Pagebake provides an intuitive API for defining routes, handling redirects, and rendering static HTML pages.
Features
-
Routing and Rendering: Define custom routes that map to page-rendering functions. Use simple closures to generate HTML content.
-
Redirect Support: Easily configure redirects that work with static hosting services, as well as out-of-the box via plain HTML.
-
Fallback Handlers: Specify fallback pages for unmatched routes to improve user experience.
-
Router Composition: Merge and nest routers to build modular and scalable site architectures.
-
Flexible Output Options: Render your site directly to disk or generate an in-memory map of files for further processing.
Installation
Via Cargo
Add Pagebake to your Cargo.toml:
From Source
Clone the repository and build it:
If you use Nix, simply activate the development shell:
Usage
Defining Routes
Create a new router and register your routes with rendering functions or redirects:
use RenderConfig;
use ;
Nesting Routers
Organize your site by nesting routers for different sections:
use ;
Redirects and Custom Rendering
Pagebake supports custom redirect page rendering. By default, a simple HTML page is generated that uses meta tags and JavaScript to perform the redirect. Custom renderers can also be configured.
For advanced redirect list generation (e.g. for Cloudflare Pages or Static Web Server), use the provided configurations in the redirects module.
use RedirectList;
use RenderConfig;
use ;
Contributing
Contributions to Pagebake are welcome! If you have suggestions, encounter issues, or want to contribute new features, please open an issue or submit a pull request.