How to Move Blog Posts From Medium to Gatsby

A more appealing, readable, and up-to-date version of this story is available on my personal blog.

In the story, I will explain how I moved all my posts from Medium to Gatsby website so that you could do the same in less time.

Why Did I Move Everything From Medium

As I continued working at my job, studying at university, and making side projects, the number of Medium posts grew. After years of writing on the platform, I decided that it is time to move everything to my websites because of several reasons.

1. Medium Partner Program

Once I learned about the program, I get excited — let’s make some money on Medium! I went to the “Medium Partner Program” page…

I was in Belarus, and there is no Stripe in Eastern European countries — I couldn’t make money from my writing.

2. No Support For Series

3. Hard to Promote Anything

But what if you want to promote another product, or you want to change the text or gif? In this case, you will manually go over each page and update every post. There is no API to help you. The last time I had to change the gif, I decided to automate the process and spend two days to make a program that goes over each post and update it in the browser.

After realizing that I have so little leverage with the platform and that it is so easy to make your custom blog with Gatsby, I decided it is the time to move.

Programmatically Moving Posts From Medium to Gatsby

Once I had a new Gatsby project, I went to the Medium export URL and got all my posts in a zip archive.

We could describe the whole process of converting raw HTML posts to Gatsby-ready Markdown with one script(cook_medium.sh).

unzip medium-export.zip -d medium-export
mv medium-export/posts posts
node filter-posts.js
medium2gatsby books_posts -o content/blog -t template.js -d

There is a Medium post with the list of summaries that the filter-posts.js script will convert to a JSON file. We will need it later to render the list of summaries in the same order as they are on Medium. Then it will go over each summary post, rename files, and change HTML. The last step is to use a library that will convert Medium posts to markdown.

Manually Moving Posts From Medium to Gatsby

I decided to keep the meta section of the blog minimalistic, to have buttons on the right side with a link that the reader most likely would like to visit — there is a list of resources in meta.

---
date: "2018-05-22"
title: "Deploy Jupyter Notebook to AWS Lambda"
description: "These days it is possible to deploy a function from Jupiter Notebook in less than a minute."
category: "programming"
keywords: [AWS Lambda, Jupyter Notebook, Python, DevOps, Terraform]
featuredImage: main.png
resources: [
GitHub https://github.com/RodionChachura/deploy-notebook
]
---

If you are curious about how to manage a series of posts with Gatsby, you could explore the repository and find answers there!

Canonical Links

There are more topics worth covering, but I wanted to keep this post short. You could fill up the gaps by exploring repositories or by reaching out to me. I hope this post was helpful to you!

Reach the next level of focus and productivity with increaser.org.

Increaser

Software engineer, creator of increaser.org. More at geekrodion.com