Migrating your blog from Medium to a platform like Jekyll or Hugo can feel daunting. But fear not! This guide will walk you through using a fantastic command-line tool, medium-2-md, which simplifies the process of converting exported Medium posts into markdown files compatible with Jekyll or Hugo. Plus, it downloads images and adds YAML front matter automatically!
Steps to Use medium-2-md
Here’s how to convert your local Medium exports into markdown files:
1. Convert Local Medium Exports
- Export your Medium Posts
- Visit your Medium settings and click on “Download your information”.
- Click the export button to get a medium-export.zip file containing all your content.
- Extract the .zip archive to reveal a “posts” sub-directory.
- Copy the path to this posts directory.
- Install node.js and medium-2-md
- Download and install node.js from nodejs.org.
- Install medium-2-md globally using npm:
npm i -g medium-2-md
.
- Run the Conversion Command
Use the following command to convert all your Medium posts into markdown files:
medium-2-md convertLocal path_of_posts_directory -dfi
The output markdown files will be stored in a sub-directory named md_a, with a unique folder name generated for each conversion.
2. Optional Flags
The convertLocal
command also supports several optional flags:
-f
or--frontMatter
: Add front matter to markdown files.-i
or--images
: Download images to a local img sub-directory.-t
or--timeout
: Set a custom timeout (default is 100ms) for downloading images.-op
or--path
: Specify a custom path for saving markdown files.-ip
or--img-path
: Specify a custom path for image downloads.-d
or--drafts
: Convert drafts as well.
3. Examples of Using Convert Command
Here are some examples using the convert command:
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
4. Custom Output and Image Paths
When using the -op
or --path
flag, the markdown files will be written to the custom path specified. If the path is invalid, they will revert to the default location. Similarly, images can be directed to a custom directory using --img-path
.
Troubleshooting
If you encounter issues during the conversion process, consider these troubleshooting tips:
- Ensure Node.js is properly installed and accessible in your command line environment.
- Check that you have the right permissions to read the Medium export directory and write to the output directory.
- If images are not downloading, verify that the
--images
flag is included in your command. - For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.
At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.
Conclusion
By following these straightforward steps, you can effortlessly convert your Medium posts into Jekyll or Hugo compatible markdown files. Happy blogging!