Embedding images inside a GitHub wiki (gollum) repository?

The Github wikis are backed by a separate git repository then the main project repository.

This post by the Github team makes it sound like you should be able to link to images stored in the wiki repository inside the wiki markup.

  • Which files should I tell my VCS to ignore when using Sphinx for documentation?
  • Arrows direction in ProGit book
  • Why should I store my Wiki in a separate Repository?
  • What documents should be stored in version control and how should they be stored?
  • Is there a way to get colored text in Github Flavored Markdown?
  • How to keep documentation history separate from source history?
  • Images and Folders

    You can now reference images hosted inside the Git repository.

    I’ve checked out my wiki’s repository and pushed a resource folder and an image into it. My question is, how do I go about using this image?

    Is this even possible or have I misunderstood something?

  • Install specific branch from github using Npm
  • GitHub solution for personal repo
  • Push with Git Bash works, but fails with Git Gui
  • Git doesnt ignore some of the files
  • Prevent download of whole git repository
  • GIT fails when pushing large files/sites
  • 14 Solutions collect form web for “Embedding images inside a GitHub wiki (gollum) repository?”

    To use relative paths do:

    [[foo.jpg]]
    

    For more info, see the demo wiki’s page on images.

    For viewers wishing to view images on a github wiki I’ve found the following method to work:

    • Go to the “Git Access” tab inside the wiki page of your repository and retrieve the SSH path which should be some thing like: git@github.com:USER/REPO.wiki.git where USER is your account name and REPO is the repository name.
    • On your local machine use what every Git command line tool you wish to cd into your local directory of choice and get the repository via

      git clone git@github.com:USER/REPO.wiki.git

    • Now within this repository create an image directory, I’ll call it “images” and put whatever images you want into the directory

    • And then push your wiki git directory to github
    • You will not be able to physically see the images in say the “Pages” tab, but if you simply reference the images in a local link you should be able to see them. Example with Markdown below:

      ![Alt attribute text Here](images/YOURIMAGE.ext)

    • You may also embed the image as a link itself by wrapping it further like so:

      [![Alt attribute text Here](images/YOURIMAGE.ext)](http://Yoursite.com)

    You can also add subdirectories within your local copy to help organize the wiki since the “pages” tab simply lists them out. Keep in mind, however, that even when the new directory is pushed the “pages” tab doesn’t list the directory.

    None of answers seem to work when adding an image in readme.md. I’ve got a solution though:

    If the URL of the image is:

    https://github.com/Username/Repository-Name/blob/master/Directory-Inside-Repository/image.png
    

    Replacing blob with raw gives you the URL of the raw image:

    https://github.com/Username/Repository-Name/raw/master/Directory-Inside-Repository/image.png
    

    Now, you’d embed the image using normal markdown:

    ![Image Alt](https://github.com/Username/Repository-Name/raw/master/Directory-Inside-Repository/image.png)
    

    UPDATE: As of now, GitHub also serves raw images from a different sub-domain raw.github.com. So, you can also use:

    https://raw.github.com/Username/Repository-Name/master/Directory-Inside-Repository/image.png
    

    EXAMPLE: https://raw.github.com/Automattic/liveblog/master/screenshot-1.png

    Relative path work for me like this:

    home page of the wiki:

    ![text](wiki/images/someimage.png)
    

    sub page of the wiki:

    ![text](images/someimage.png)
    

    Note that when doing a preview the image will not show, I had save it.

    If you want to quickly upload an image with drag/drop, you can perform the following (albeit hackish):

    Create a dummy issue; drag & drop your image there; copy/paste the uploaded markdown image code to your wiki;

    After you create the issue once, you can use it any number of times to do this.

    Hope this helps anyone looking for a quick fix, without needing to have the image reside in the repo.

    Figured it out.

    The url is formatted as follows

    https://raw.github.com/wiki/username/project/pathtoimage/imagename.extension

    pathtoimage is optional

    James’ URL format did not work for me, perhaps it has been changed. I have used:

    https://github.com/username/project/wiki/pathtoimage/image.extension

    Where pathtoimage is optional.

    Finally got the images into repository using the method described by nerdwin and got them to display in the wiki using ![test](test.jpg)

    The following markdown will reference an image in your GitHub repo from within your corresponding GitHub wiki

    ![My Alt Text](../blob/master/Path/ToAsset/In/Repo.png?raw=true)
    

    The above example assumes that you have the following file structure in your repo

    • Path
      • ToAssets
        • In
          • Repo.png

    For a real world example, if I wanted to reference this image in github from the corresponding wiki, I’d use this markdown

    ![Azure App Settings](../blob/master/TrelloWorld/TrelloWorld.Server/Assets/Azure_AppSettings.png?raw=true)
    

    Caveats

    1. Case matters
    2. If you are on the special Home page of the wiki, you do not need to go up a level with the ../ In my example above, the correct link would be

    For Home Page:

    ![Azure App Settings](blob/master/TrelloWorld/TrelloWorld.Server/Assets/Azure_AppSettings.png?raw=true)
    

    To embed an external image thumbnail, use the following,

    ![Image](<external link to the image>)

    Use the relative path

    the Wiki is located at [repositoryname]/wiki

    The files in the repository are located at [repositoryname]/raw/master/[file path in repository]

    So just use the relative path: ../raw/master/[file path in repository]

    I put both images and PDFs in my wikis. I clone the wiki and add an images and a files directory, then use the following markdown to embed image links and add file links:

    Images:

    [[/images/path/to/image.ext|ALT TEXT]]
    

    The leading slash isn’t necessary if your wiki pages are all at the root level, but I use subdirectories and an absolute path resolves correctly and keeps things simple.

    Files:

    [link text](files/path/to/file.ext "ALT TEXT")
    

    Note, no leading slash for the wiki files path to resolve correctly as a link in this format.

    I documented this in a GitHub gist

    The comment from @Drew Noakes to the original question did it for me:

    The syntax for the image I wanted to be displayed:

    [[/images/imageName.png]]
    

    This image was only displayed when renaming:

    wikiPage.md --> wikiPage.wiki
    

    The following folder structure was used in the wiki repository:

    repository.wiki
       |--wikiPage.wiki
       |--images
            |--imageName.png       
    

    BUT:

    The syntax in .wiki differs from .md files.

    Here is a practical way to do it:

    • Go to any issue on github
    • In the comment section you can attach files, just drag/drop, select or paste your image
    • Copy the code/link displayed in the textarea
    • Paste it in the wiki
    • Profit !

    You don’t even have to create or modify any issue compared to @tiby solution !

    Git Baby is a git and github fan, let's start git clone.