Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Copilot Lvl 3
Message 1 of 9

Image Path when the file isn't in the root

Solved! Go to Solution.

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

8 Replies
Pilot Lvl 3
Message 2 of 9

Re: Image Path when the file isn't in the root

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](/assets/screenshot.png). There's some more info on this over here: https://jekyllrb.com/docs/posts/#including-images-and-resources 🙂

 

Let me know how you go

Copilot Lvl 3
Message 3 of 9

Re: Image Path when the file isn't in the root

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

Solution
Pilot Lvl 3
Message 4 of 9

Re: Image Path when the file isn't in the root

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)
Commander Lvl 2
Message 5 of 9

Re: Image Path when the file isn't in the root

The path of the link in github markdown follow the linux convention, so the second example that give @ItsPugle 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-

Copilot Lvl 3
Message 6 of 9

Re: Image Path when the file isn't in the root

Hello

 

You win  :-)

I use the two dots and the Problem was solved.

 

Thank you very match for your kind help

 

Greetings

Peter

Pilot Lvl 3
Message 7 of 9

Re: Image Path when the file isn't in the root

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!

Ground Controller Lvl 2
Message 8 of 9

Re: Image Path when the file isn't in the root

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 :)

Ground Controller Lvl 1
Message 9 of 9

Re: Image Path when the file isn't in the root

Same issue here.