Migrating my blog from Gatsby to a static site with Cryogen and AsciiDoctor
A year ago I have moved my blog from Wordpress and its WYSIWYG editor to a static site written using React and GaphQL and generated by Gatsby, with entries in Markdown, hosted on Netlify. My motivation was control and ease of writing. Now I continue the trend by moving from Gatsby to Cryogen, a blog-focused static site generator in Clojure, and AsciiDoctor.
We use Gatsby at work for Telia’s cellphone B2B webshop and it is a perfect match - the site is very interactive and (statically generated) React makes a lot of sense there.
But Gatsby does many things and is consequently very complex. It offers many cool features, such as automatically generating and loading images of optimal sizes for different devices, code splitting, content preloading and offline caching for a truly single page app (SPA) experience. But I need just a blog. There is close to zero interactivity so I do not need a huge pile of JavaScript, old good HTML is good. I don’t want to send both HTML and the JS code to generate the HTML to the clients. And, more than anything, I want small, simple system that I can understand and tweak. Gatsby gave me too many headache (admittedly partly due to the way I tried to misuse it).
Cryogen is a tiny tool with great documentation and a responsive and welcoming maintainer and it is written in Clojure, the language that I enjoy most of all.
I also decided to move from Markdown to AsciiDoctor - it is better defined and has a richer feature set, providing out-of-the-box some functionality that I missed before (or had to use Gatsby plugins for), such as the ability to assign custom classes to code blocks, IDs to headings, better ability to mix HTML and the markup, <aside>
. See the short overview at AsciiDoc vs Markdown and Why You Shouldn’t Use “Markdown” for Documentation.
The migration process
The code for migrating from Gatsby to Cryogen is in the blog repo:
content/tmp-migration/old/md/
is the old Gatsby contentto-adoc.fish runs Pandoc with a custom template and a filter to transform the content from .md to .asc and then the babashka (scripting in ± Clojure) script fix-files.clj to fix Cryogen metadata blocks and other things
Finally,
tmp-migration/combine-all.sh
moves the content to where it should be
(The Wordpress content has been previously extracted from the wordpress backup XML into posts.json by the blog2md-master Node.js script and is migrated by wordpress_json_migration.clj.)