A Ruby script that converts a Ghost blog post into a Markdown file with YAML frontmatter, ready for cross-posting to platforms like dev.to. Originally created to republish SerpApi blog posts.
- Extracts post metadata like title, description, tags, cover image, publication date, and canonical URL
- Converts Ghost post content (
section.post-full-content) to Markdown viareverse_markdown - Handles Ghost bookmark cards, rendered as Markdown list links
- Handles Ghost image cards, preserves images with alt text and captions
- Handles Ghost callout cards, rendered as Markdown blockquotes with emoji
- Preserves code blocks with language syntax hints
- Generates a YAML frontmatter preamble compatible for dev.to
- Saves output to
<slug>.mdderived from the post URL
Install dependencies:
bundle installRun the script with a Ghost post URL:
ruby ghost-repub.rb <post-url>You can also make it executable and move it to your PATH:
chmod +x ghost-repub.rb
mv ghost-repub.rb /usr/local/bin/ghost-repubExample:
ghost-repub https://yourblog.com/my-post/The script saves the result to my-post.md in the current directory.
Here's how to use the output to republish to different platforms.
The output should be immediately pastable into the dev.to editor as is. Some Ghost blocks formatting might not be implemented, so it's worth to do a quick visual scan.
The output body should be immediately pastable into the Hashnode editor. However, you need to use the metadata from the frontmatter to set the title, tags, and canonical URL. To set canonical URL, add it under Publish -> Discovery -> Set Canonical URL. You also need to reupload your cover image.
Feel free to open a PR.
© 2026 SerpApi