Skip to content
jalogisch

back to jekyll - moving 1358 posts out of ghost

· blog development nginx

This blog started in 2005 on WordPress. At that time I worked at Host Europe, and the blog ran on the shared hosting platform I was responsible for and helped to develop. So it was also my own test case: I needed something real running on it to test my own work. And it connected me to the big “blogosphere” of these days. Many blogs ran on WordPress, and a lot of them at Host Europe. I was not allowed to talk about the technical side of my job, so the blog became my emotional letterbox and not a technical one.

Some years later it was a Jekyll site (with Jekyll Bootstrap, if you remember that), and in October 2019 it moved to Ghost. Now it is back to Jekyll. Plain HTML files, built on my laptop and copied to a server. No database, no Node process, no admin login that wants updates.

Why? I am going back to KISS - keep it simple, stupid. Simple is not bad. In a world that gets more complicated every year, simple might be exactly right. So this move is a conscious step to have less: less software, less to update, less that can break. A blog does not need a running application with a database.

And to be honest: when I wanted to start, I could not even log in to my own Ghost anymore.

So here are my notes on the move. I write them down for the future me, and maybe it helps someone with the same problem.


no export? read the database

The clean way out of Ghost is the JSON export in the admin area. Without a working login, there is no export. But my Ghost ran on SQLite, so all posts sit in one file: content/data/ghost.db.

I opened it read only and only looked at the content tables:

sqlite3 -readonly ghost.db \
  "select type, status, count(*) from posts group by type, status;"

page|published|3
post|published|1358
post|draft|2

Keep away from the other tables. users, sessions, api_keys and members hold password hashes and personal data. Nothing of that belongs into a static site or a git repository.

The good news: Ghost keeps the original text. Old posts are stored as a mobiledoc document with one markdown card inside. For 1351 of my 1358 posts I could take that markdown as it was. Only the few posts from the newer editor needed a detour: HTML through pandoc (pandoc -f html -t gfm), followed by a small cleanup script.

Every post got its old address as permalink in the front matter. The addresses stay the same as in Ghost (/<year>/<slug>/), so no redirects inside the blog are needed. One small trap: the year in the address comes from the time zone of the blog. Ghost ran with Europe/Amsterdam, so Jekyll needs the same timezone, or a post from New Year’s Eve lands in the wrong year.

And yes, I found leftovers from the first Jekyll time: {% include JB/setup %} in 1302 posts from 2005 to 2011. Seven years in Ghost and nobody noticed.

1358 posts, 52 stay

This was the harder part, and it was not technical. 1234 posts are from 2005 to 2008. Links, videos, quotes, how I felt that day. An LLM helped me sort and count, which made this much faster. Then I went through the list and decided: technical posts and personal texts I still stand for stay public. Everything else goes into an archive folder inside the repository. Jekyll does not build folders that start with an underscore, so _archiv/ is never published, but nothing is deleted.

The result: 52 old posts are online, about 1300 are in the archive. Technical posts older than 2020 start with a note that the details are probably out of date. I would rather say that than pretend my Docker notes from 2019 still work like that.

410 instead of 404

What happens to all the old links that point to archived posts? A 404 Not Found would be a lie. I know exactly where they are. HTTP has a status for that: 410 Gone, which means “this was here and it is not coming back” (RFC 9110, 15.5.11).

A small Python script reads every permalink from _archiv/ and writes nginx rules. A visitor gets the 410 status and, as body, a short page that explains why the post is gone:

error_page 410 /2026/aufgeraeumt/index.html;
# one block per archived post, with and without the slash at the end
location = /2007/some-old-post/ { return 410; }
location = /2007/some-old-post  { return 410; }

The script stops if a path looks strange or if a post is in the archive and public at the same time. With about 1300 generated lines, I want it to fail loud rather than produce a broken config.

The old Ghost addresses get the same treatment: the feed stays at /rss/, /author/... goes to the about page, /page/2/ goes to the start page.

build without ruby

I do not want Ruby on my laptop. Jekyll runs fine in a container:

podman run --rm -v "$PWD":/site:ro -v "$PWD/_site":/out -w /tmp \
  docker.io/library/ruby:3.4.12-alpine3.24 \
  sh -c 'apk add -q build-base && gem install -N jekyll -v 4.4.1 &&
         jekyll build -s /site -d /out --disable-disk-cache'

The source is mounted read only, the output goes to a separate folder. That folder goes to the server, nothing else.

what I lose

The editor in the browser, scheduled posts, members and newsletters. What I get: less. A site that is only files, a strict Content-Security-Policy with no external scripts, a dark mode, and posts that are text files in git. I can grep my own blog again.

Now the hard part starts: writing again.