95

I want to display some images in a Markdown file on Github. I found it works this way:

![Figure 1-1](https://raw.github.com/username/repo/master/images/figure 1-1.png "Figure 1-1")

But i need to collaborate with others so i don't want the username and repo name hard coded .

I tried to use this:

![Figure 1-1](images/figure 1-1.png "Figure 1-1")

It works on my local disk but not work on Github.

Is there anyone knows about this issue?

NoDataDumpNoContribution
  • 10,591
  • 9
  • 64
  • 104
WoooHaaaa
  • 19,732
  • 32
  • 90
  • 138

2 Answers2

156

I found the answer myself.

Just simply append ?raw=true to the image url will make the trick:

![](images/table 1-1.png?raw=true)
WoooHaaaa
  • 19,732
  • 32
  • 90
  • 138
  • 3
    This works for me when viewing the Markdown files directly on GitHub, but not for the README.markdown file displayed on the project's main page. – jmohr Oct 28 '12 at 17:20
  • @jmohr I think README files on the main page should be treated as an exception. – WoooHaaaa Oct 29 '12 at 03:42
  • This worked on the README file on the main page for me. – Mike Grace Aug 09 '14 at 18:49
  • 1
    Github still doesn't allow SVG even with `raw`. http://stackoverflow.com/questions/13808020/include-an-svg-hosted-on-github-in-markdown – Yeo Feb 11 '15 at 14:27
30

I just had the same issue and it turned out to be caused by the space in the URL. Manually URL encoding the space as %20 fixed it.

So using your example I changed:

![](images/table 1-1.png)

to:

![](images/table%201-1.png)

2021 Edit: Thanks Emilio for pointing out that the GitHub flavored markdown spec has been updated to allow spaces in filenames when the filename is enclosed inside "pointy" (angle) brackets:

The destination can only contain spaces if it is enclosed in pointy brackets
Example 498
[link](</my uri>) --> <p><a href="/my%20uri">link</a></p>

Ref: https://github.github.com/gfm/#example-498 (scroll up for description)

This works with images too so we can now also use:

![](<images/table 1-1.png>)
foz
  • 3,121
  • 1
  • 27
  • 21
  • 2
    They must've changed the spec since then because it now allows spaces if enclosed in pointy brackets. https://github.github.com/gfm/#example-497 – Emilio Mar 12 '21 at 03:21