A CLI tool that converts medium posts (html) into Jekyll/Hugo compatible markdown files. Also downloads images and adds yaml front matter to the converted markdown files. It works with exported Medium posts (local html files) and converts them to markdown using a single command. It can be useful in scenarios when you want to migrate your blog away from Medium to Jekyll or Hugo (or something similar that supports markdown content).
https://medium.com/me/settings/security and click on Download your information. Click the export button. This will allow you to download a medium-export.zip archive containing all your Medium content.posts.posts directory.node.js and medium-2-md on your system.npm i -g medium-2-md.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 md_<a big number> in the input posts directory itself. (By the way, that big number is coming from the Date.now() JavaScript function, added to differentiate multiple output folders.)
The converted markdown files include front matter containing title, description, published date and canonical URL of the original Medium post/story. The images from the Medium posts are downloaded in a sub-directory called img inside the output directory.
The convertLocal command supports the following optional flags,
-f or --frontMatter: Add the front matter on top of the markdown files.-i or --images: Download images to a local img sub-directory.-t or --timeout: Set the timeout for downloading images. Default is 100ms.-op or --path: Custom path for saving markdown files.-ip or --img-path: Custom path for downloading images.-d or --drafts: Convert the drafts too.medium-2-md convertLocal '/home/user/Desktop/posts' -fi
medium-2-md convertLocal '/home/user/Desktop/posts' -dfi
medium-2-md convertLocal '/home/user/Desktop/posts' -dfi --path '/home/user/Desktop/md' --img-path '/home/user/Downloads/img'
Note: The flags do not support any defaults. You need to add them in order to get the respective results (drafts, images and/or front matter inclusion).
When using the -op or the --path flag, the output markdown files are written to this path instead of the default value. If this custom path is invalid or does not exist, the output files are written to the default path.
When using the -i or --images with the --img-path flag, the images are downloaded into the directory at this custom path. If this directory does not already exist, the images are downloaded to the default path. The image elements in the converted markdown files link to their respective local paths.
This package uses: