How to include images when importing blog posts?

I’m trying to import several blog posts from Gatsby/markdown to Ghost through a script, following Importing content from other platforms to Ghost

How do I include the images from such posts in the migration process? I have all of them stored locally and they are already pointed in the markdown/json files. Thx!

Hit the images endpoint to upload the image. Record the handle returned. Edit the blog post content/featured image for the new url to point to the image. Make the post.

2 Likes

Thank you for the help, @Cathy_Sarisky :pray:

Could you please clarify/detail “hit the images endpoint”? I forgot to mention that I’m a super noobie and I’m writing a script line by line with quite some struggle :sweat_smile:

Are you using the SDK? Highly recommended.

Here’s an example in Mark’s post:

2 Likes

Someone can correct me if I’m wrong, but I think if the URLs aren’t changing, or can be fixed with a find/replace of the base URL, then you can copy the images manually to the content folder of your Ghost instance.

I believe Ghost will create smaller sizes of the images on-demand if needed.

If I’m wrong, then yes, using the API or the migration package is the way to go.

You can look for example at the source code of the Jekyll importer, which is another Markdown-based blog solution.

Ghost Pro users need to use the API, Mark. :)