pagebake
pagebake is a simple, modular static site generator library. 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, or out-of-the box via plain HTML.
-
Fallback Handlers: Specify fallback pages for unmatched routes.
-
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.
Installation
Via Cargo
Add pagebake to your Cargo.toml:
From Source
Clone the repository:
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, Sitemaps 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 redirect list generation (e.g. for Cloudflare Pages or Static Web Server), use the provided configurations in the redirects module.
The same applies to route lists, which can be used to generate sitemaps.
use RedirectList;
use RenderConfig;
use RouteList;
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.