https://github.com/potherca-blog/StackOverflow/blob/master/question.13808020.include-an-svg-hosted-on-github-in-markdown/readme.md
The purpose of raw.github.com
is to allow users to view the contents of a file, so for text based files (SVG, JS, CSS, etc) this means you get the wrong headers and things break in the browser.
Update:
Github has implemented a feature which makes it possible for SVG's to be used with the Markdown image syntax. The SVG image will be sanitized and displayed with the correct HTTP header. Certain tags (like <script>
) are removed.
To view the sanitized SVG or to achieve this effect from other places (i.e. from markdown files not hosted in repos on http://github.com/) simply append ?sanitize=true
to the SVG's raw URL.
See the examples below for rendering details.
As the file you are trying to get to display seems to part of your projects documentation this might be a win-win situation
If using Github Pages is not your thing, rawgithub.com could be an option. RawGit retrieves your files and sets the correct headers for you.
-
As stated by AdamKatz in the comments, using a source other than github.io can introduce potentially privacy and security risks. See the answer by CiroSantilli and the answer by DavidChambers for more details.
-
As stated by MonsieurDart in the comments, RawGit does not work for private repos.
-
The issue to resolve this was opened on Github on October 13th 2015 and was resolved on August 31th 2017
I copied the SVG image from the question to a repo on github in order to create the examples below:
Linking to relative files (Works, but obviously only https://github.com/)

<img src="./controllers_brief.svg">

<img src="https://raw.github.com/potherca-blog/StackOverflow/master/question.13808020.include-an-svg-hosted-on-github-in-markdown/controllers_brief.svg">

<img src="https://raw.github.com/potherca-blog/StackOverflow/master/question.13808020.include-an-svg-hosted-on-github-in-markdown/controllers_brief.svg?sanitize=true">
Linking to files hosted on github.io (Works)

<img src="https://potherca-blog.github.io/StackOverflow/question.13808020.include-an-svg-hosted-on-github-in-markdown/controllers_brief.svg">
Linking to RAW files using rawgithub.com (Also Works)
Note: Sometimes the RawGithub service is down/doesn't work. If you don't see an image below, that is probably the case.

<img src="https://rawgithub.com/potherca-blog/StackOverflow/master/question.13808020.include-an-svg-hosted-on-github-in-markdown/controllers_brief.svg">