No description
  • JavaScript 67%
  • Nunjucks 15%
  • CSS 14.1%
  • HTML 2.5%
  • Python 1.1%
  • Other 0.3%
Find a file
2026-11-11 20:56:17 +01:00
_includes Gallery photos: width/height attributes, high priority for the first feed photo 2026-11-11 20:44:02 +01:00
admin platte-dingen + lineendings? 2026-10-08 16:56:46 +02:00
docs Style the tags index, remove old tag-page CSS, update docs 2026-10-15 11:20:14 +02:00
lib platte-dingen + lineendings? 2026-10-08 16:56:46 +02:00
nginx anti crawler measures 2026-10-14 09:12:18 +02:00
scripts more css moving 2026-10-13 22:58:48 +02:00
static CSS cleanup: remove duplicate and unused rules, modern visually-hidden 2026-11-11 20:28:21 +01:00
.dockerignore platte-dingen + lineendings? 2026-10-08 16:56:46 +02:00
.env.example platte-dingen + lineendings? 2026-10-08 16:56:46 +02:00
.gitattributes platte-dingen + lineendings? 2026-10-08 16:56:46 +02:00
.gitignore platte-dingen + lineendings? 2026-10-08 16:56:46 +02:00
add_tags.py platte-dingen + lineendings? 2026-10-08 16:56:46 +02:00
AGENTS.md Style the tags index, remove old tag-page CSS, update docs 2026-10-15 11:20:14 +02:00
build-watch.js platte-dingen + lineendings? 2026-10-08 16:56:46 +02:00
build.js Gallery photos: width/height attributes, high priority for the first feed photo 2026-11-11 20:44:02 +01:00
dev-server.js added 50x error page 2026-10-08 15:22:07 +02:00
docker-compose.yml platte-dingen + lineendings? 2026-10-08 16:56:46 +02:00
Dockerfile platte-dingen + lineendings? 2026-10-08 16:56:46 +02:00
package-lock.json platte-dingen + lineendings? 2026-10-08 16:56:46 +02:00
package.json platte-dingen + lineendings? 2026-10-08 16:56:46 +02:00
README.md Remove missing-photos.md: the post was deleted 2026-11-11 20:56:17 +01:00
robots.txt anti crawler measures 2026-10-14 09:12:18 +02:00
WORKLOG.md Remove missing-photos.md: the post was deleted 2026-11-11 20:56:17 +01:00
worth-fixing.md Update worth-fixing.md: mark done items 2026-11-11 20:25:09 +01:00

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 in content/, so it takes no extra disk space (it falls back to a copy when content/ 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.

  1. 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/
    
  2. Check the owner. The container runs as uid/gid 1000 (user: in docker-compose.yml). id -u and id -g should print 1000, and ls -ld static-alway static-alway/content should show your user. If not, change user: in the stack's copy (step 3). Every file in content/ must belong to that user too: Linux only allows hard links to files you own (fs.protected_hardlinks). Otherwise the build logs Can't hard link originals (EPERM), copying them instead. Check with find content -type f ! -uid 1000 (should print nothing); fix with sudo 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
    
  3. Create the stack from the repo's compose file and .env.example, copied unchanged:
    mkdir -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
    
    The .env sets PROJECT_DIR to the project folder; edit it if the project lives elsewhere. Name the stack folder alway-static-admin; it matches the project name in the file.
  4. Build the image in a terminal, not in Dockge:
    cd /mnt/courage/filepile/webs/swillbe/static-alway
    docker build -t alway-static-admin .
    
    Dockge runs docker compose inside 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 no build:; 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.
  5. Start it: deploy the alway-static-admin stack in Dockge (or docker compose up -d in 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 into public/:
    docker exec alway-static-admin npm run build
    
  6. Pangolin: add a resource with target http://<server-ip>:11081.
  7. Web container (its own stack): mount /mnt/courage/filepile/webs/swillbe/static-alway/public read-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, so docker compose up also works from the project folder itself.
  • image: alway-static-admin with pull_policy: never: the image you build by hand (step 4). There's no build: 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 and PORT.

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-alway on the host.
  • Neither terminal has node or docker. To build, rely on the dev server, which rebuilds preview/ on every change (compare the timestamps of preview/ with the files you edited), or run docker exec alway-static-admin node build.js --drafts from 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)