- JavaScript 67%
- Nunjucks 15%
- CSS 14.1%
- HTML 2.5%
- Python 1.1%
- Other 0.3%
| _includes | ||
| admin | ||
| docs | ||
| lib | ||
| nginx | ||
| scripts | ||
| static | ||
| .dockerignore | ||
| .env.example | ||
| .gitattributes | ||
| .gitignore | ||
| add_tags.py | ||
| AGENTS.md | ||
| build-watch.js | ||
| build.js | ||
| dev-server.js | ||
| docker-compose.yml | ||
| Dockerfile | ||
| package-lock.json | ||
| package.json | ||
| README.md | ||
| robots.txt | ||
| WORKLOG.md | ||
| worth-fixing.md | ||
alway.swill.be
Static site for alway.swill.be: photography and writing. A small custom Node.js build
(build.js) turns Markdown posts and photos into plain HTML. A dev server with a
browser admin, running in Docker, is where posts are written, previewed and published.
content/ ──► build.js --drafts ──► preview/ served by the dev server (with drafts)
▲ + admin UI at /admin
│ admin writes posts + photos
│
└─────────► build.js ──► public/ the published site, served by a
(admin: Publish) separate web container
Project layout
| Path | What |
|---|---|
content/ |
Posts, pages and their photos. Not in git, back it up separately. |
_includes/ |
Nunjucks templates: layouts/ (page types) and partials/ (gallery, feed entries). |
static/ |
Files copied as-is to the root of the site: the favicons. |
build.js |
The build: reads content/, renders the templates, processes photos, writes feeds. |
lib/ |
Code shared by the build and the admin (collections.js URL prefixes, slug.js). |
dev-server.js |
Serves preview/, rebuilds it when content/, _includes/, static/ or build.js change, hosts the admin. |
admin/ |
Admin UI (public/), its API (server.js) and the Publish job (publish.js). |
build-watch.js |
Like the dev server's rebuilds, without the web server. |
scripts/import-wordpress.js |
One-off importer from the old WordPress site. |
scripts/make-favicons.js |
Makes favicon.ico and apple-touch-icon.png from static/favicon.svg; run again after changing the SVG (docker exec alway-static-admin node scripts/make-favicons.js). |
nginx/ |
Config for the web container that serves public/ (mounted in from the server). |
preview/, public/ |
Build output (not in git). |
.admin-trash/ |
Posts deleted in the admin, recoverable (not in git). |
Content
Dated posts
One folder per post, named after its date; a second post on the same day gets -2, and so on:
content/photoblog/2026-10-02/
├── post.md
└── images/
├── IMG_1680.jpeg
└── IMG_1695.jpeg
post.md is front matter plus Markdown text. The date comes from the folder name, the URL
slug from the title:
---
title: Testpost
description: ''
tags:
- snapseed
galleries:
- title: Testpost
images:
- filename: IMG_1680.jpeg
wide: true # a row of its own (others go two per row)
- filename: IMG_1695.jpeg
caption: Hengelo # used as the photo's alt text
draft: true # only in the preview, left out when publishing
---
Text below the photos.
Collections and URLs
| Collection | Folder | Post URL | Listing |
|---|---|---|---|
| Photo blog | content/photoblog/ |
/blogs/photoblog/2026/10/02/<slug>/ |
Feed on / and /blogs/photoblog/ |
| Lofi | content/lofi/ |
/blogs/lofi/… |
Feed on /blogs/lofi/ (no titles shown) |
| Writing | content/writing/ |
/blogs/writing/… |
Feed on /blogs/writing/ |
| Platte dingen | content/platte-dingen/ |
/blogs/platte-dingen/… |
Feed, once it has a post |
| Found art | content/found-art/ |
/found-art/… |
Feed on /found-art/ |
| Urbexing | content/urbexing/ |
/projects/photography/urbexing/… |
Feed, with content/projects/photography/urbexing.md as its intro |
| Now | content/now/ |
/now/… |
/now/ |
Feeds show 5 posts per page (/page/2/, …). Every tag gets a page at /tags/<tag>/.
The site also gets feed.xml (RSS) and sitemap.xml. Prefixes live in
lib/collections.js, feed settings in build.js (GALLERY_COLLECTIONS, FEED_COLLECTIONS).
Pages
Markdown files without a date in their path are pages, with the URL taken from the file name, so editing a title doesn't change the URL:
content/about/me.md→/about/me/content/projects/photography/index.md→/projects/photography/content/bookmarks.md→/bookmarks/
A page can have its own images/ folder for photos placed in its text. Short redirects
(/colophon, /about) are set in REDIRECTS in build.js.
Photos
For every photo in an images/ folder the build writes:
<name>-900w.jpg: scaled to 900px wide (JPEG quality 85), shown on the page;<name>.<ext>: the untouched original, opened when you click the photo. This is a hard link to the file incontent/, so it takes no extra disk space (it falls back to a copy whencontent/and the output are on different mounts).
<output>/.image-cache.json remembers what was made from which photo, so a rebuild only
processes new or changed photos.
Editing a photo in place in content/ also changes the published original right away
(it's the same file); tools that save a new file don't have that effect.
Running it (Docker)
The dev server runs in a container; the server needs only Docker and a checkout of this
repo, no Node or npm. The image holds the dependencies (/srv/node_modules) and the
project folder is mounted at /srv/app.
Server setup
The server keeps compose stacks and project files apart:
~/services/stacks/alway-static-admin/ the stack: compose.yaml + .env
/mnt/courage/filepile/webs/swillbe/static-alway/
this repo + content/, preview/, public/, .admin-trash/
Nothing goes in ~/services/appdata/: the app's only data is content/, preview/ and
public/, and they must stay together in the project folder on one file system (ext4),
or the hard-linked originals turn into copies.
- Check out the project and put the content in it (
content/isn't in git):cd /mnt/courage/filepile/webs/swillbe git clone https://git.swill.be/rob/alway-swill-be-static-blog-site.git static-alway # copy content/ over, e.g. from the PC: rsync -a content/ server:/mnt/courage/filepile/webs/swillbe/static-alway/content/ - Check the owner. The container runs as uid/gid 1000 (
user:indocker-compose.yml).id -uandid -gshould print 1000, andls -ld static-alway static-alway/contentshould show your user. If not, changeuser:in the stack's copy (step 3). Every file incontent/must belong to that user too: Linux only allows hard links to files you own (fs.protected_hardlinks). Otherwise the build logsCan't hard link originals (EPERM), copying them instead. Check withfind content -type f ! -uid 1000(should print nothing); fix withsudo chown -R 1000:1000 content, then remove the copies so the next builds link them (only touches the output folders):find preview public -path '*/images/*' -type f ! -name '*-900w.jpg' -delete - Create the stack from the repo's compose file and
.env.example, copied unchanged:
Themkdir -p ~/services/stacks/alway-static-admin cd /mnt/courage/filepile/webs/swillbe/static-alway cp docker-compose.yml ~/services/stacks/alway-static-admin/compose.yaml cp .env.example ~/services/stacks/alway-static-admin/.env.envsetsPROJECT_DIRto the project folder; edit it if the project lives elsewhere. Name the stack folderalway-static-admin; it matches the project name in the file. - Build the image in a terminal, not in Dockge:
Dockge runscd /mnt/courage/filepile/webs/swillbe/static-alway docker build -t alway-static-admin .docker composeinside its own container, which can't see/mnt/courage, so it can't build this image (unable to prepare context: path "…/static-alway" not found). The compose file therefore has nobuild:; it uses this local image and never pulls (pull_policy: never). Mounting the project folder into the container works from Dockge, because the Docker daemon on the host resolves volume paths. - Start it: deploy the
alway-static-adminstack in Dockge (ordocker compose up -din the stack folder). The first build resizes every photo, which takes a while; follow it in the stack's log. Then run the first publishing build intopublic/:docker exec alway-static-admin npm run build - Pangolin: add a resource with target
http://<server-ip>:11081. - Web container (its own stack): mount
/mnt/courage/filepile/webs/swillbe/static-alway/publicread-only as the site root. It needs nothing else from this project.
When docker-compose.yml changes in the repo, the stack's copy doesn't follow by
itself. After a git pull, check and copy it again:
diff /mnt/courage/filepile/webs/swillbe/static-alway/docker-compose.yml ~/services/stacks/alway-static-admin/compose.yaml
Settings
In docker-compose.yml (and so in the stack's copy):
PROJECT_DIR(from.env): the project folder, mounted into the container. Defaults to the folder the compose file is in, sodocker compose upalso works from the project folder itself.image: alway-static-adminwithpull_policy: never: the image you build by hand (step 4). There's nobuild:in the compose file, so Dockge never tries to build.user: "1000:1000": files the container writes are owned by your user.PORT: the port the dev server listens on inside the container (default 11081).ports: "11081:11081": published on the server, for Pangolin to connect to. Login is Pangolin's job (the admin itself has none), but this port answers anyone who can reach the server, without that login, and Docker's published ports bypass ufw. To change the port, change both numbers here andPORT.
Don't put a node_modules folder in the project; Node would use it instead of the image's.
Day to day
Stack commands run in ~/services/stacks/alway-static-admin (or use Dockge's buttons);
git pull and docker build run in the project folder.
| Task | Command |
|---|---|
| Watch the builds | docker compose logs -f dev |
After git pull (code, admin) |
docker compose restart dev |
After a change to package.json or the Dockerfile |
docker build -t alway-static-admin . (project folder), then docker compose up -d (or redeploy in Dockge) |
| Publishing build by hand | docker compose exec dev npm run build |
| Preview build by hand | docker compose exec dev npm run build:drafts |
Template changes in _includes/ and build.js are picked up by the watcher; no restart needed.
Terminal for coding agents
Run commands in the agent-host terminal, not the default VS Code terminal.
- The default terminal is a shell inside the code-server container (user
abc). Commands typed there didn't run or return output for the agent. - The agent-host terminal runs in the project folder and returns output. Inside code-server
that folder is
/data/webs/swillbe/static-alway, the same project as/mnt/courage/filepile/webs/swillbe/static-alwayon the host. - Neither terminal has
nodeordocker. To build, rely on the dev server, which rebuildspreview/on every change (compare the timestamps ofpreview/with the files you edited), or rundocker exec alway-static-admin node build.js --draftsfrom the host.
Writing and publishing
The admin (/admin) edits the photo blog, lofi, found art, urbexing, platte dingen and now collections:
create and edit posts, upload and reorder photos, mark photos wide, manage tags, and mark a
post as draft. It writes the same content/ files you could edit by hand; the dev server
rebuilds the preview after each save. Deleting a post moves its folder to .admin-trash/.
Publish runs the publishing build (node build.js): drafts left out, written to
public/. The web container that serves public/ (outside this project) needs no
restart; it serves the new files right away. It only needs public/ mounted (read-only
is fine), not content/.
The build writes an error page for unknown URLs to public/404.html (from
_includes/layouts/404.njk). The dev server serves it for the preview; the web container
serving public/ has to be told to use it, e.g. error_page 404 /404.html; in nginx or
try_files {path} /404.html in Caddy. The admin keeps its own plain error responses.
The build also writes public/50x.html (from _includes/layouts/50x.njk) for server errors.
nginx/default.conf already points 500–504 responses at it; the dev server shows it for 500s too.
WordPress import
scripts/import-wordpress.js fetches posts from the old WordPress site's REST API into
content/. Re-running skips posts it imported before. See the comment at the top of the
script for options (--dry-run, --limit, --page):
docker compose exec dev node scripts/import-wordpress.js --dry-run
Docs
| Doc | What |
|---|---|
| ARCHITECTURE.md | How the pieces fit together, and the decisions behind them |
| BUILD.md | What build.js does step by step, its settings, adding a collection |
| TEMPLATES.md | The layouts and partials in _includes/ and what they get |
| ADMIN.md | What the admin edits and writes, Publish, its API |
| IDEAS.md | Ideas not built (yet) |