Ghost Blog backup to Astro markdown

Ghost Blog backup to Astro markdown
Photo by Šimom Caban / Unsplash

The Problem:

I believe I have mentioned here in the past my desire to leave the Ghost Blog platform in favor of using Astro for at least some of my blogs.

To be clear, I love the Ghost platform, but I've long been interested in moving to a more simplistic static hosting solution. I find that Ghost is a bit more than I really need and, at least for most of my use cases, more overhead than I'd prefer. I've looked at using multiple options such as Gatsby. Not too long ago I had Astro recommended and I've been playing with it ever since and found it very much to my liking.

The issue that I encountered was that I have not been able to find a useful tool or tutorial that would allow me to easily migrate my posts from Ghost to Astro.

Ghost has long had a backup feature. More recent versions of Ghost include a backup tool in the CLI. The backups that produces a zip archive containing your content and various metadata related to your Ghost Blog

I found one useless tutorial that pointed to a tool that claimed to convert Ghost Blog's backup to markdown files but the issues and commit history suggested it is quite outdated. The last commit was in 2019. The tutorial itself is incomplete even if the tool it referenced worked.

The Solution:

Write it myself was the path I chose.

Here's an embedded a gist with some placeholders that accomplishes my goal, broadly:

This solution isn't perfect. There are myriad improvements and optimizations possible, but it served my needs pretty well recently and I felt it was worth sharing for anyone else looking to accomplish this same goal.

I think it's pretty self explanatory. It uses Turndown to convert the HTML in the JSON backup file to Markdown and then outputs each post as its own Markdown file.

Good luck and feel free to reach out if you have any questions.