How to display an image in readme file on Github?

Viewed 5125

I'm trying to display an image on my readme.md file on my git repo. I've done this before in my other repos, but for some reason this doesn't work this time.

Currently my code produces the following in the readme file:

enter image description here

I tried:

![Model](path_to_img.pdf)

Which just makes the link open the folder where the image is and show it

I also tried

![Model](link_address_to_image)

Which does the same thing.

I also tried

![Model](path_to_img.pdf?raw=true)

Which makes the link download the image

1 Answers

That display means you aren't linking to the file path. Unfortunately github is really finicky about how it loads images in readme's and you have to use their domain specifically for serving static content. If your image is part of your repo you need to access the file via the raw.githubusercontent.com subdomain specifically the pattern is https://raw.githubusercontent.com/<username>/<repo name>/<branch>/<path to file>.

For example on this project since the homepage image is in ./.github/logo.png and on the master branch of https://github.com/Descent098/ezcv I had to do:

![ezcv logo](https://raw.githubusercontent.com/Descent098/ezcv/master/.github/logo.png)

Edit

Looking at your post I just noticed you have a .pdf file not a .png. PDF's can't be loaded using the inline image syntax, since they aren't inline images. There is a pseudo-solution here, but there's no real clean way to do it otherwise.

Related