.md: Import image

1 minute read

How to write images url correctly in .md file?

Today, I wrote a markdown file for my website, everything worked perfect when I checked it in preview.

preview

But unfortunately, I couldn’t see images when I post .md file on my blog website.

errorImg

I checked web page by developer tools, then found that /assets floder is inside /blog directory.

source

So I add /blog before old image link, the images come back again!

imagelink2

This is my first time to write blog on Jekyll webstie, I checked Doc about Image standard. They suggest people using

{{ site.url }}{{ site.baseurl }}/assets/images/

It doesn’t show images in my web page. I remeber {site.url} is my Github base url and {site.baseurl} is my repositories name. My repositories name is “blog”, What a coincidence! So I replace my image link as:

newLink

Those two ways both working, but I think the frist one is retrive image sources from local directory and second one is retrive from url link, maybe the first one execute more fast. I will update this blog when I know more about browser machanism and Jekyll.

At begin, I used .png as image file postfix, when I run it in local host, all images can show correctly. But it should be .PNG which I get screen shot by Snipping Tool, if not, all images can’t find in website.