Image Path when the file isn't in the root

Hello

When i have my image in a folder named “Image” and my file “sample.md” is in the Root, then i access the picture “pix.jpg” with the path “image\pix.jpg”. But how i access the the picture, when the file “sample.md” is in a subfolder?

That means “sample.md” ist in the folder “/_posts” and the pictures are in the folder “/image”. I tryed with the prefix “[repository]/image/pix.jpg”. Nothing works. Please a little information to solve my confusion.

Greetings
Peter

2 Likes

Hey there @petergyger, help’s arrived. 

You can reference static files (like images) to your Jekyll posts by adding it them to a subdirectory like /assets and then referencing that in Markdown: a screenshot example. There’s some more info on this over here: https://jekyllrb.com/docs/posts/#including-images-and-resources 🙂

Let me know how you go

1 Like

Hello

So sorry - but don’t work. the Directory Structure:

[Repro Test]

¦-_posts

¦-images

In the directory “_posts” is a markdown file “sample.md”. In this file i link the Image “pic.jpg” from the Folder “images”. How? There is no way that work. I habe no Problems, when  the Markdown File is in the Root and i write a static link to “images/pic.jpg”.

I read the Jeckyll Manual and i followed your link. But for my question there is no solution.

Greetings

Peter

1 Like

Thanks for letting me know @petergyger,

Let’s check if adding a forward slash before the reference helps. For example:

![this screenshot](/assets/pic.png)

If that doesn’t help, let’s check if adding " " to before the first forward slash helps:

![this screenshot](../assets/pic.png)
11 Likes

The path of the link in github markdown follow the linux convention, so the second example that give @timrossback should work. If not you can give to us the tree of the projects/repository and we can help in a better way.

There is another way to link image, using the absolute path like this:

![this screenshot](https://github.com/username/repository/blob/branch/path/pic.png)

-Gabriele-

3 Likes

Hello

You win  :slight_smile:

I use the two dots and the Problem was solved.

Thank you very match for your kind help

Greetings

Peter

2 Likes

You’re more than welcome @petergyger

If you need a hand with anything else, just let me know or feel free to post a new thread in the Conversations board 🌟

Have a great day!

2 Likes

Hi All

I am also facing the issue for relative link. following the same structre as above , only diffence is i need to link .md file from _pages/ to _posts/.md.

i can see .md file https://aartirajput1.github.io/JekyllSiteRepo/JekyllSiteRepo/adding/ but not rendedered in HTML , its showing 404 error not found.

_post/.md file : https://github.com/aartirajput1/JekyllSiteRepo/blob/master/_posts/2019-04-05-Homepage.markdown

Please help.

Thanks in advance :slight_smile:

1 Like

Same issue here.

The nice thing about correcting the paths, rather than starting again re-adding your images if they have got ‘lost’, is that each individual image’s attributes when originally placed in the file, its size, offset, whether the image has a frame around it, etc is kept next to the reference to the image. Adding a new image requires all of these attributes adding manually again.

Yes! I very much appreciate your recommendation. Even I also thinking the same as what you said for the better image solution.  Every idea shared, and every opportunity seized by you helped us achieve the heights. Your dedication is imperative for the growth of many people. Thank you for your efforts. Your attention to detail at work makes you more unique. Keep up the good work.

Very Beautiful Article Thanks For Sharing. I have Provided Latest Dard Bhari Shayari in Hindiand Attitue Status

This look good. But can we use thin our dynamic website? Kindly guide me regarding this.