Use this Python 3 script to convert a folder of Jekyll posts (MarkDown files with YAML headers) into a Ghost-compatible JSON file to import into your Ghost blog.
Edit the input/output directions at the top of the script, as necessary.
post_directory = '../_posts/' new_filename = 'jekyll_to_ghost.json'
Given the diversity of YAML header parameter names in Jekyll themes, you'll likely need to customize those parameter names in the script before successfully converting your blog posts into a Ghost-compatible JSON file.
This script assumes that the images for your Jekyll blog are hosted in
/assets/images/ and that your images for your Ghost blog are hosted in
/content/images/. If that is not the case, edit the script to reflect your directory structure(s).
This script will not move your images or other embedded content for you. Be sure to do that separately.
Importing into Ghost
Once your JSON file is successfully created, use Ghost's import tool (in
Labs, as of version 1.0) to import your Jekyll export into Ghost. If there are mistakes, use the delete option in
Labs to delete your blog database and re-import the corrected file.
Static pages (other than blog posts) will need to be converted separately. You can do so using the same functions in this script, but modifications will be necessary.
Updates and pull requests
This script worked for my site (which used the Casper Jekyll theme created by the Ghost team). However, if you notice any issues attempting to convert your site, please feel free to submit an issue (or better yet, a pull request!). No promises for a quick reply, but I'll do what I can.