This blog is a static site generated by Zola and served straight out of an S3 bucket. No server, no database, just files.
How it’s published#
A single command builds the site and syncs it to the bucket:
just publishUnder the hood, scripts/publish.sh runs zola build and then pushes public/ with whichever S3 client is installed:
rclone sync public/ "$remote" --checksum \
--header-upload "Cache-Control: public, max-age=300"Assets go up first, then HTML, so a page never points at a stylesheet that isn’t there yet.
| Files | Cache lifetime |
|---|---|
| HTML, feeds | 5 minutes |
| CSS, fonts | 1 day |
Put images next to the post’s
index.mdand link them relatively. Zola copies colocated assets alongside the page.
The bucket name must match the hostname when using an S3 website endpoint.
Some code#
use std::collections::HashMap;
/// Counts words in a string.
fn word_count(text: &str) -> HashMap<&str, usize> {
let mut counts = HashMap::new();
for word in text.split_whitespace() {
*counts.entry(word).or_insert(0) += 1;
}
counts
}