Adding Images to Gatsby Blog in Markdown
Posted on 2019-08-26Ok I spent the past 3 hours trying to find out this annoying little thing. Spoiler alert: You DON'T NEED any Gatsby plugins. Stop reading these lies. (JK, some plugins allows you to enjoy Gatsby's image optimization feature, but unfortunately the documentation is too bad - I tried everything but nothing worked for me. Hence this original hack-y solution.)
All you need:
- Create a folder in your "public" folder. Call it "images". Put your image files into this folder.
- Refer to your image in your markdown file by typing this:
![](/images/image_name.png)
- You need to commit your public folder. Run
git add -f /public/images
because usually your public folder is in git ignore