I am using Next.js as they support static and server side render which is awesome, and they have great integration with Redux-toolkit which is something I am trying to practice in all of my projects.
Within my portfolio I will have the pages render the content of a markdown file. As you might know, if you export your details from Medium you will get a .zip file with ALL of your content, like comments, posts, reactions. Luckily they are all really nicely organized in a directory.
Instructions on how to do that:
Unfortunately all of the posts are exported in HTML. So of course I started thinking of a package to create that will convert the HTML pages people get exported from Medium into Markdown files.
This is the spot where we all have to go, “If I have thought of it, there is probably a package already”.
medium-2-md (yeah, that’s what I’m calling it) is a simple CLI tool which takes a directory containing Medium posts’ HTML files and converts them into markdown. Not only that, but it downloads images and also adds a rich front matter to these converted markdown files so that they can be directly used in Jekyll or Hugo. — Gautam Dhameja (creator)
Gautam gives a great usage tut
medium-2-md is available as an npm package so that it can be easily downloaded and used without the need of going through the code. All you need to do is download and install it (globally) and then use it directly from the command line. Follow the steps listed below to use medium-2-md.
Step 1: Export and extract your Medium posts from your Medium account.
- Go to https://medium.com/me/settings and scroll to
Download your information. Click the download button. This will give you a
medium-export.ziparchive containing all your Medium content.
- Extract the .zip archive downloaded in the previous step. It will have a sub-directory called
- Copy the path of this
Step 2: Install node.js and medium-2-md on your system.
- Download and Install node.js —
- Install medium-2-md package —
npm i -g medium-2-md.
-g flag means that you are installing the package globally. It is essential in order to use the package directly from the command prompt/terminal.
Step 3: Run the following command to convert all your Medium posts (HTML) to markdown files.
medium-2-md convertLocal '<path of the posts directory>' -dfi
That’s it. The output markdown files will be stored in a sub-directory called
The converted markdown files will also have front matter which will have the title, description, published date and canonical URL of the original Medium post/story. Images will be downloaded inside a sub-directory in the output directory.
More details about the package are available in the readme file at the medium-2-md GitHub repository.
Worked like a charm for me and saved me a bunch of time. 💜 Thank you!