Gatsby: Question: Referencing images from markdown posts?

Created on 8 Oct 2017  ยท  6Comments  ยท  Source: gatsbyjs/gatsby

I created a blog with the tutorial on gatsbyjs.org. However, I am unable to reference to images in my markdown - I did some googling and no obvious solution exists.

Here's my current folder structure:

โ”œโ”€โ”€ layouts
โ”‚ย ย  โ””โ”€โ”€ index.js
โ”œโ”€โ”€ pages
โ”‚ย ย  โ”œโ”€โ”€ 404.js
โ”‚ย ย  โ”œโ”€โ”€ art.js
โ”‚ย ย  โ”œโ”€โ”€ contact.js
โ”‚ย ย  โ”œโ”€โ”€ index.js
โ”‚ย ย  โ”œโ”€โ”€ my-files.js
โ”‚ย ย  โ”œโ”€โ”€ static
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ some-image.jpg
โ”‚ย ย  โ””โ”€โ”€ work.js
โ”œโ”€โ”€ posts
โ”‚ย ย  โ”œโ”€โ”€ 2016-04-04-some-post.md
โ”œโ”€โ”€ templates
โ”‚ย ย  โ””โ”€โ”€ blog-post.js
โ””โ”€โ”€ utils
    โ””โ”€โ”€ typography.js

TLDR: how do I reference some-image.jpg from the single post written in markdown?

Most helpful comment

For anyone that finds this post lacking,
Assuming you have a folder structure like:

โ”œโ”€โ”€ pages
โ”‚   โ”œโ”€โ”€ post-title
โ”‚   โ”‚   โ”œโ”€โ”€ index.md
โ””โ”€โ”€ โ””โ”€โ”€ โ””โ”€โ”€ image.jpg

You can reference the image from inside the post like so:

![](./image.jpg)

Make sure you've got gatsby-transformer-remark and gatsby-remark-images installed and configured.

All 6 comments

Maybe looking at Mathews' blog can help?

Thanks, I was able to solve this (a bug due to migration)

@thevangelist It is always, good practice to describe what went wrong, how you found out, and how you resolved it. Just in case somebody else has a bug at the same point and comes here looking.

;) Came here looking.

I think this is what @thevangelist was referring to: https://github.com/gatsbyjs/gatsby-starter-blog/issues/113#issuecomment-408619291

After Migrating to v2 there was a breaking change which was patched by gatsby@^2.0.0-beta.61 and gatsby-transformer-remark@^2.1.1-beta.5.

In my case, I also still needed to install gatsby-remark-images and its dependency, gatsby-plugin-sharp. Hope this helps anyone else who comes looking!

For anyone that finds this post lacking,
Assuming you have a folder structure like:

โ”œโ”€โ”€ pages
โ”‚   โ”œโ”€โ”€ post-title
โ”‚   โ”‚   โ”œโ”€โ”€ index.md
โ””โ”€โ”€ โ””โ”€โ”€ โ””โ”€โ”€ image.jpg

You can reference the image from inside the post like so:

![](./image.jpg)

Make sure you've got gatsby-transformer-remark and gatsby-remark-images installed and configured.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

brandonmp picture brandonmp  ยท  3Comments

rossPatton picture rossPatton  ยท  3Comments

3CordGuy picture 3CordGuy  ยท  3Comments

ferMartz picture ferMartz  ยท  3Comments

totsteps picture totsteps  ยท  3Comments