Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

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?

like image 401
James McMahon Avatar asked Apr 06 '12 15:04

James McMahon


People also ask

How do I add an image to a Wiki in GitHub?

Using the wiki sidebar, navigate to the page you want to change, and then click Edit. On the wiki toolbar, click Image. In the "Insert Image" dialog box, type the image URL and the alt text (which is used by search engines and screen readers). Click OK.

How do I embed an image in GitHub?

You can drag and drop the image from your computer to a comment field in GitHub. Wait for the file to upload and then the URL to the image is right there! You don't even have to submit the issue if you don't want to (although that may limit the image's lifespan).


2 Answers

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: [email protected]:USER/REPO.wiki.git where USER is your account name and REPO is the repository name.
  • On your local machine use whichever Git command line tool you wish to cd into your local directory of choice and get the repository via

    git clone [email protected]: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.

like image 83
Ryan Q Avatar answered Sep 27 '22 18:09

Ryan Q


To use relative paths do:

[[foo.jpg]] 

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

like image 22
Benjamin Oakes Avatar answered Sep 27 '22 17:09

Benjamin Oakes