Embedding images inside a GitHub wiki (gollum) repository? - github

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?

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 whichever 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.

To use relative paths do:
[[foo.jpg]]
For more info, see the demo wiki's page on images.

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.

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 !

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
Case matters
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)

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 with more detail in a GitHub gist

Since Feb. 2022, you can simply drag and drop, select or paste the file.
That will upload the image to your Wiki pages, and store it in https://user-images.githubusercontent.com

To embed an external image thumbnail, use the following,
![Image](<external link to the image>)

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.

Many of the answers didn't work for me, here's what finally worked:
![](../raw/master/Images/ImportantImage.png)
Using the "Markdown" editor mode and a sub-page such as:
https://github.com/project/repo/wiki/MyPage

Related

How to display an image in readme file on Github?

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:
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
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.
upload your picture or file to github.
open that file in github and copy its link.
open Readme.md file and type ![Model](Paste_link_here)
enjoy!

Add google drive images to README.md on GitHub

Recently I joined GitHub. I am hosted some projects there.
I need to include some my GoogleDrive images in my README File. I don't know how to do that.
First, get a share-able link to your Google Drive image so anyone can view it.
Then, the GitHub-flavored markdown for an image is what you're looking for:
![optional-description-here](link-here)
This is the syntax for an image to be loaded from a link. My favorite example:
![StackOverflow logo](https://www.stackoverflowbusiness.com/hubfs/B2B-SO/images/logo-so-PRINT-4.png)
I even added a public example for you here on my GitHub

How to add images to README.md on GitHub?

Recently I joined GitHub. I hosted some projects there.
I need to include some images in my README File. I don't know how to do that.
I searched about this, but all I got was some links which tell me to "host images on web and specify the image path in README.md file".
Is there any way to do this without hosting the images on any third-party web hosting services?
Try this markdown:
![alt text](http://url/to/img.png)
I think you can link directly to the raw version of an image if it's stored in your repository. i.e.
![alt text](https://github.com/[username]/[reponame]/blob/[branch]/image.jpg?raw=true)
You can also use relative paths like
![Alt text](relative%20path/to/img.jpg?raw=true "Title")
Also try the following with the desired .fileExtention:
![plot](./directory_1/directory_2/.../directory_n/plot.png)
You can create a New Issue
upload(drag & drop) images to it
Copy the images URL and paste it into your README.md file.
here is a detailed youTube video explained this in detail:
https://www.youtube.com/watch?v=nvPOUdz5PL4
It's much simpler than that.
Just upload your image to the repository root, and link to the filename without any path, like so:
![Screenshot](screenshot.png)
You can also add images with simple HTML tags:
<p align="center">
<img src="your_relative_path_here" width="350" title="hover text">
<img src="your_relative_path_here_number_2_large_name" width="350" alt="accessibility text">
</p>
Many of the posted solutions are incomplete or not to my taste.
An external CDN like imgur adds another tool to the chain. Meh.
Creating a dummy issue in the issue tracker is a hack. It creates clutter and confuses users. It's a pain to migrate this solution to a fork, or off GitHub.
Using the gh-pages branch makes the URLs brittle. Another person working on the project maintaining the gh-page may not know something external depends on the path to these images. The gh-pages branch has a particular behavior on GitHub which is not necessary for hosting CDN images.
Tracking assets in version control is a good thing. As a project grows and changes it's a more sustainable way to manage and track changes by multiple users.
If an image applies to a specific revision of the software, it may be preferable to link an immutable image. That way, if the image is later updated to reflect changes to the software, anyone reading that revision's readme will find the correct image.
My preferred solution, inspired by this gist, is to use an assets branch with permalinks to specific revisions.
git checkout --orphan assets
git reset --hard
cp /path/to/cat.png .
git add .
git commit -m 'Added cat picture'
git push -u origin assets
git rev-parse HEAD # Print the SHA, which is optional, you'll see below.
Construct a "permalink" to this revision of the image, and wrap it in Markdown.
Looking up the commit SHA by hand is inconvenient, however, so as a shortcut press Y to a permalink to a file in a specific commit as this help.github page says.
To always show the latest image on the assets branch, use the blob URL:
https://github.com/github/{repository}/blob/assets/cat.png
(From the same GitHub help page File views show the latest version on a branch)
You can also insert animated SVG images in the markdown file like any other format.
It can be a good alternative to GIF images.
![image description](relative/path/in/repository/to/image.svg)
OR
<img src="relative/path/in/repository/to/image.svg" width="128"/>
Example (assuming the image is in assets directory in the repository):
![My animated logo](assets/my-logo.svg)
Result:
To use different images based on GitHub dark/light theme see this post.
Very Simple : Can be done using Ctrl + C/V
Most of the answers here directly or indirectly involve uploading the image somewhere else & then providing a link to it.
It can be done very simply by just copying any image and pasting it while editing Readme.md
Copying the image - You can just click on the image file and use Ctrl + C or may copy the screenshot image to your clipboard using the snipping tool
You can then simply do Ctrl + V while editing Readme.md
Guithub will automatically upload it to user-images.githubusercontent.com and a link to it will be inserted there
I need to include some images in my README File. I don't know how to
do that.
I created a small wizard that allows you to create and customize simple image galleries for your GitHub repository's readme: See ReadmeGalleryCreatorForGitHub.
The wizard takes advantage of the fact that GitHub allows img tags to occur in the README.md. Also, the wizard makes use of the popular trick of uploading images to GitHub by drag'n'dropping them in the issue area (as already mentioned in one of the answers in this thread).
Commit your image (image.png) in a folder (myFolder) and add the following line in your README.md:
![Optional Text](../master/myFolder/image.png)
Basic Syntax
![myimage-alt-tag](url-to-image)
Here:
my-image-alt-tag : text that will be displayed if image is not shown.
url-to-image : whatever your image resource is. URI of the image
Example:
![stack Overflow](http://lmsotfy.com/so.png)
This will look like the following:
Create an issue regarding adding images
Add the image by drag and drop or by file chooser
Then copy image source
Now add ![alt tag](http://url/to/img.png) to your README.md file
Done!
Alternatively you can use some image hosting site like imgur and get it's url and add it in your README.md file or you can use some static file hosting too.
Sample issue
Just add an <img> tag to your README.md with relative src to your repository. If you're not using relative src, make sure the server supports CORS.
It works because GitHub support inline-html
<img src="/docs/logo.png" alt="My cool logo"/>
# My cool project and above is the logo of it
Observe here
You can now drag and drop the images while editing the readme file.
Github will create a link for you which will be in the format of:
https://user-images.githubusercontent.com/******/********.file_format
Alternatively, at the bottom of the file, it says "Attach files by dragging & dropping, selecting or pasting them". If you click on that one, it will give you an option to upload a file directly or you can just paste it!
You Can use
![A test image](image.png)
Where ![A test image] is your alt text and (image.png) is the link to your image.
You can have the image on a cloud service or other online image hosting platforms
Or you can provide the image link from the repository if it is in the repo
You can also make a specific folder inside your repository dedicated to your readme images
Step by step process,
First create a folder ( name your folder ) and add the image/images that you want to upload in Readme.md file. ( you can also add the image/images in any existing folder of your project. )
Now,Click on edit icon of Readme.md file,then
![](relative url where images is located/refrence_image.png) // refrence_image is the name of image in my case.
After adding image, you can see preview of changes in the, "Preview Changes" tab.you will find your image here.
for example like this,
In my case,
![](app/src/main/res/drawable/refrence_image.png)
app folder -> src folder -> main folder -> res folder -> drawable folder -> and inside drawable folder refrence_image.png file is located.
For adding multiple images, you can do it like this,
![](app/src/main/res/drawable/refrence_image1.png)
![](app/src/main/res/drawable/refrence_image2.png)
![](app/src/main/res/drawable/refrence_image3.png)
Note 1 - Make sure your image file name does not contain any spaces. If it contain spaces then you need to add %20 for each space between the file name. It's better to remove the spaces.
Note 2 - you can even resize the image using HTML tags, or there are other ways. you can google it for more.
if you need it.
After this, write your commit changes message, and then commit your Changes.
There are many other hacks of doing it like, create a issue and etc and etc. By far this is the best method that I have came across.
Use tables to stand out, it will give separate charm to it
Table Syntax is:
Separate each column cell by symbol |
and table header (First row) by 2nd row by ---
| col 1 | col 2 |
|------------|-------------|
| image 1 | image 2 |
output
Now just put <img src="url/relativePath"> at image 1 and image 2 if you are using two images
Note: if using multiple images just include more columns, you may use width and height attribute to make it look readable.
Example
| col 1 | col 2 |
|------------|-------------|
| <img src="https://media.wired.com/photos/5926db217034dc5f91becd6b/master/w_582,c_limit/so-logo-s.jpg" width="250"> | <img src="https://mk0jobadderjftub56m0.kinstacdn.com/wp-content/uploads/stackoverflow.com-300.jpg" width="250"> |
Spacing does not matter
Output image
helped by : adam-p
In new Github UI, this works for me -
Example - Commit your image.png in a folder (myFolder) and add the following line in your README.md:
![Optional Text](../main/myFolder/image.png)
You can just do:
git checkout --orphan assets
cp /where/image/currently/located/on/machine/diagram.png .
git add .
git commit -m 'Added diagram'
git push -u origin assets
Then you can just reference it in the README file like so:
![diagram](diagram.png)
JUST THIS WORKS!!
take care about your file name uppercase in tag and put PNG file inroot, and link to the filename without any path:
![Screenshot](screenshot.png)
Just README.md file inside write down the code here [Anyname](image path)
![Screenshot](screenshot1.png)
Although GitHub markdown can also add pictures I will suggest you use an HTML IMG tag
GitHub Markdown
![me](https://github.com/samadpls)
HTML TAG
<img src='https://github.com/samadpls'/>
I usually host the image on the site, this can link to any hosted image. Just toss this in the readme. Works for .rst files, not sure about .md
.. image:: https://url/path/to/image
:height: 100px
:width: 200 px
:scale: 50 %
I have solved this problem. You only need to refer to someone else's readme file.
At first,you should upload an image file to github code library ! Then direct reference to the address of the image file .
In my case i use imgur and use the direct link this way.
![img](http://i.imgur.com/yourfilename.png)
You can link to images in your project from README.md (or externally) using the alternative github CDN link.
The URL will look like this:
https://cdn.rawgit.com/<USER>/<REPO>/<BRANCH>/<PATH>/<TO>/<FILE>
I have an SVG image in my project, and when I reference it in my Python project documentation, it does not render.
Project link
Here is the project link to the file (does not render as an image):
https://github.com/jongracecox/anybadge/blob/master/examples/awesomeness.svg
Example embedded image:
Raw link
Here is the RAW link to the file (still does not render as an image):
https://raw.githubusercontent.com/jongracecox/anybadge/master/examples/awesomeness.svg
Example embedded image:
CDN link
Using the CDN link, I can link to the file using (renders as an image):
https://cdn.rawgit.com/jongracecox/anybadge/master/examples/awesomeness.svg
Example embedded image:
This is how I am able to use images from my project in both my README.md file, and in my PyPi project reStructredText doucmentation (here)
There are 2 simple way you can do this ,
1) use HTML img tag ,
2) ![](the path where your image is saved/image-name.png)
the path would you can copy from the URL in the browser while you have opened that image.
there might be an issue occur of spacing so make sure if there is any space b/w two words of path or in image name add-> %20. just like browser do.
Both of them will work , if you want to understand more you can check my github -> https://github.com/adityarawat29
This Answer can also be found at:
https://github.com/YourUserAccount/YourProject/blob/master/DirectoryPath/ReadMe.md
Display images from repo using:
prepend domain: https://raw.githubusercontent.com/
append flag: ?sanitize=true&raw=true
use <img /> tag
Eample url works for svg, png, and jpg using:
Domain: raw.githubusercontent.com/
UserName: YourUserAccount/
Repo: YourProject/
Branch: YourBranch/
Path: DirectoryPath/
Filename: example.png
Works for SVG, PNG, and JPEG
- `raw.githubusercontent.com/YourUserAccount/YourProject/YourBranch/DirectoryPath/svgdemo1.svg?sanitize=true&raw=true`
Working example code displayed below after used:
**raw.githubusercontent.com**:
<img src="https://raw.githubusercontent.com/YourUserAccount/YourProject/master/DirectoryPath/Example.png?raw=true" />
<img src="https://raw.githubusercontent.com/YourUserAccount/YourProject/master/DirectoryPath/svgdemo1.svg?sanitize=true&raw=true" />
raw.githubusercontent.com:
Thanks:
- https://stackoverflow.com/a/48723190/1815624
- https://github.com/potherca-blog/StackOverflow/edit/master/question.13808020.include-an-svg-hosted-on-github-in-markdown/readme.md
I am just extending or adding an example to the already accepted answer.
Once you have put the image on your Github repo.
Then:
Open the corresponding Github repo on your browser.
Navigate to the target image file Then just open the image in a new tab.
Copy the url
And finally insert the url to the following pattern ![alt text](https://raw.githubusercontent.com/username/projectname/branch/path/to/img.png)
On my case it is
![In a single picture](https://raw.githubusercontent.com/shadmazumder/Xcode/master/InOnePicture.png)
Where
shadmazumder is my username
Xcode is the projectname
master is the branch
InOnePicture.png is the image, On my case InOnePicture.png is in the root directory.
In my case I wanted to show a print screen on Github but also on NPM. Even though using the relative path was working within Github, it wasn't working outside of it. Basically, even if I pushed my project to NPM as well (which simply uses the same readme.md, the image was never showing.
I tried a few ways, at the end this is what worked for me:
![Preview](https://raw.githubusercontent.com/username/project/master/image-path/image.png)
I now see my image correctly on NPM or anywhere else that I could publish my package.

How to add screenshot to READMEs in github repository?

Is it possible to place a screenshot in README file in a GitHub repository? What's the syntax?
If you use Markdown (README.md):
Provided that you have the image in your repo, you can use a relative URL:
![Alt text](/relative/path/to/img.jpg?raw=true "Optional Title")
If you need to embed an image that's hosted elsewhere, you can use a full URL
![Alt text](http://full/path/to/img.jpg "Optional title")
GitHub recommend that you use relative links with the ?raw=true parameter to ensure forked repos point correctly.
The raw=true parameter is there in order to ensure the image you link to, will be rendered as is. That means that only the image will be linked to, not the whole GitHub interface for that respective file. See this comment for more details.
Check out an example: https://raw.github.com/altercation/solarized/master/README.md
If you use SVGs then you'll need to set the sanitize attribute to true as well: ?raw=true&sanitize=true. (Thanks #EliSherer)
Also, the documentation on relative links in README files: https://help.github.com/articles/relative-links-in-readmes
And of course the markdown docs: http://daringfireball.net/projects/markdown/syntax
Additionally, if you create a new branch screenshots to store the images you can avoid them being in the master working tree
You can then embed them using:
![Alt text](/../<branch name>/path/to/image.png?raw=true "Optional Title")
Even though there is already an accepted answer I would like to add another way to upload images to readme on GitHub.
You need to create issue in your repo
Drag and drop in the comment area your image
After link for the image is generated insert it to your readme
More details you can find here
I found that the path to the image in my repo did not suffice, I had to link to the image on the raw.github.com subdomain.
URL format https://raw.github.com/{USERNAME}/{REPOSITORY}/{BRANCH}/{PATH}
Markdown example ![Settings Window](https://raw.github.com/ryanmaxwell/iArrived/master/Screenshots/Settings.png)
JUNE 3, 2020 : WORKING ANSWER-
Upload your image to postimage.org
Copy Github-Markdown-Url after uploading Image
Insert in your ReadMe
One line below should be what you looking for
if your file is in repository
![ScreenShot](https://raw.github.com/{username}/{repository}/{branch}/{path})
if your file is in other external url
![ScreenShot](https://{url})
The markdown syntax for displaying images is indeed:
![image](https://{url})
BUT: How to provide the url ?
You probably do not want to clutter your repo with screenshots, they have nothing to do with code
you might not want either to deal with the hassle of making your image available on the web... (upload it to a server... ).
So... you can use this awesome trick to make github host your image file. TDLR:
create an issue on the issue list of your repo
drag and drop your screenshot on this issue
copy the markdown code that github has just created for you to display your image
paste it on your readme (or wherever you want)
http://solutionoptimist.com/2013/12/28/awesome-github-tricks/
Much simpler than adding URL
Just upload an image to the same repository,
like:
![Screenshot](screenshot.png)
add this to README
<div align="center">
<img src="/screenshots/screen1.jpg" width="400px"</img>
</div>
From March 2021, this is now supported:
Attaching files to markdown files
You can now attach files, including images, to markdown files while you're editing them in the web.
This works just like file attachments in issues and pull requests and supports the same file types.
Just drag and drag, click and select, or paste.
Note: If you add an image to a markdown file, anyone can view the anonymized image URL without authentication, even if the markdown file is in a private repository.
To keep images private, serve them from a private network or server that requires authentication.
For more information on anonymized URLs see "About anonymized image URLs".
Markdown: ![Screenshot](http://url/to/img.png)
Create an issue regarding adding images
Add the image by drag and drop or by file chooser
Then copy image source
Now add ![Screenshot](http://url/to/img.png) to your README.md file
Done!
Alternatively you can use some image hosting site like imgur and get it's url and add it in your README.md file or you can use some static file hosting too.
Sample issue
Method 1->Markdown way
![Alt Text](https://raw.github.com/{USERNAME}/{REPOSITORY}/{BRANCH}/{PATH})
Method 2->HTML way
<img src="https://link(format same as above)" width="100" height="100"/>
or
<img src="https://link" style=" width:100px ; height:100px " />
Note-> If you don't want to style your image i.e resize remove the style part
For me, the relative path worked out very well.
How I did this:
In my current md file where I wanted to use a picture from another directory, I used a relative path like this - consider following points.
md file loc: base dir -> _post -> current_file.md
& picture file loc which I wanted to use: base dir -> _asset -> picture_to_use.jpeg
What the statement I used was on current_file.md file:
![your-pic-caption-name](../_asset/picture_to_use.jpeg)
Note - before this, I was using direct _asset but Ideally, it so starts from ../_asset/and-so-no
reference - https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/creating-a-repository-on-github/about-readmes
Add ![ScreenShot](screenshot.png) in the readme markdown as mentioned by many above. Replace screenshot.png with the name of the image you uploaded in your repository.
But here is a newbie tip when you upload the image (as I made this mistake myself):
ensure that your image name does not contain spaces. My original image was saved as "Screenshot day month year id.png". If you don't change the name to something like contentofimage.png, it won't appear as an image in your readme file.
I googled a few similar questions and did not see any answers with my problem and its quite simple/easy solution.
Google Cloud Storage - a slightly different approach to images in READMEs
Here goes: like the OP, I wanted an image in my Github README, and, knowing the Markdown syntax for doing so, typed it in:
![My Image](https://storage.cloud.google.com/${MY_BUCKET}/${MY_IMAGE}
You need to complete the actual substitutions above (e.g. MY_IMAGE=image.jpg) for this to work.
But, wait...failure--there's no actual rendered photo! And the link is exactly as given by Google Storage!
Github camo - Anonymous Images
Github hosts your images anonymously, yay! However, this presents an issue for Google storage assets. You need to get the generated url from your Google Cloud Console.
I'm sure there's a smoother way, however, simply visit your given URL endpoint and copy the long URL. Details:
Instructions
Visit your storage console: https://console.cloud.google.com/storage/browser/${MY_BUCKET}?project=${MY_PROJECT}
Click on the image you'd like to display in Github (this brings up the "Object Details" page)
Copy pasta that URL (the one starting with https not gs) into a new browser tab/window
Copy pasta the new generated URL -- it should be longer -- from your new browser tab/window into your Github README file
Hopefully this helps speed up and clarify this issue for anyone else.
Please fallow this four step,
this worked for me
1-Create a new issue on GitHub.
2-Drag-and-drop an image onto the comment field or upload a photo.
3-Wait for the upload process to finish.
4-Copy the URL and use it in your Markdown files on GitHub (use that generated URL in your repository's readme).
First, create a directory(folder) in the root of your local repo that will contain the screenshots you want added. Let’s call the name of this directory screenshots. Place the images (JPEG, PNG, GIF,` etc) you want to add into this directory.
Android Studio Workspace Screenshot
Secondly, you need to add a link to each image into your README. So, if I have images named 1_ArtistsActivity.png and 2_AlbumsActivity.png in my screenshots directory, I will add their links like so:
<img src="screenshots/1_ArtistsActivity.png" height="400" alt="Screenshot"/> <img src=“screenshots/2_AlbumsActivity.png" height="400" alt="Screenshot"/>
If you want each screenshot on a separate line, write their links on separate lines. However, it’s better if you write all the links in one line, separated by space only. It might actually not look too good but by doing so GitHub automatically arranges them for you.
Finally, commit your changes and push it!
To me the best way is -
Create an new issue with that repository on github and then upload the file in gif format.To convert video files into gif format you can use this website http://www.online-convert.com/
Submit the newly created issue.
Copy the address of the uploaded file
Finally in your README file put ![demo](COPIED ADDRESS)
Hope this will help .
Add image in repository from upload file option then in README file
![Alt text]("enter image url of repositoryhere")
Create a New issue by clicking on the green button in the upper right corner. Take a screenshot of whatever you need and paste it into the issue message (CMD+V on Mac or CTR+V on Windows).
My image had space in the name, e.g. Pasted image 20221006123035.png, and that was causing a problem from me, and I lost some time fixing it. If someone has the same issue, then here are the steps
I uploaded the image via upload option
Then clicked on the image in the file browsing UI of the website.
The image is opened in the browser. From the browser's URL I copied the url of the image. You can copy the whole path, or relative to your .md file
Now insert that link to the .md file like ![overview](Pasted%20image%2020221006123035.png)
With the images located in /screen-shots directory. The outer <div> allows the images to be positioned. Padding is achieved using <img width="desired-padding" height="0">.
<div align="center">
<img width="45%" src="screen-shots/about.PNG" alt="About screen" title="About screen"</img>
<img height="0" width="8px">
<img width="45%" src="screen-shots/list.PNG" alt="List screen" title="List screen"></img>
</div>

GitHub relative link in Markdown file

Is there a way to create a URL anchor, <a>, link from within a Markdown file, to another file within the same repository and branch (aka a link relative to the current branch)?
For example, in the master branch I have a README.md file, which I would like do something like:
# My Project
is really really cool. My Project has a subdir named myLib, see below.
## myLib documentation
see documentation [here](myLib/README.md)
This would allow me to link from one .md to another within the same branch and not have to worry about which branch I'm in (avoid having to do an absolute URL that includes the github.com branch name).
Here is a working example of what I mean:
GOTO http://github.com/rynop/testRel, link does not work.
GOTO http://github.com/rynop/testRel/blob/master/README.md, link works.
This is expected because at this point the starting URL is in the branch. Now how do I get it to pick up the current branch in the README.md at the root of the repository?
Update: I opened an issue against GitHub for this feature request.
Update 30th, January 2013, 16 months later:
GitHub Blog Post Relative links in markup files:
Starting today, GitHub supports relative links in markup files.
Now you can link directly between different documentation files, whether you view the documentation on GitHub itself, or locally, using a different markup renderer.
You want examples of link definitions and how they work? Here's some Markdown for you.
Instead of an absolute link:
[a link](https://github.com/user/repo/blob/branch/other_file.md)
…you can use a relative link:
[a relative link](other_file.md)
[a relative link](path%20with%20spaces/other_file.md)
and we'll make sure it gets linked to user/repo/blob/branch/other_file.md.
If you were using a workaround like [a workaround link](repo/blob/master/other_file.md), you'll have to update your documentation to use the new syntax.
This also means your documentation can now easily stand on its own, without always pointing to GitHub.
Marcono1234 adds in the comments
Also useful: When the link starts with a /, it is relative to the root of the repository (regardless of whether the markdown file is nested in subdirectories)
Update December 20th, 2011:
The GitHub markup issue 84 is currently closed by technoweenie, with the comment:
We tried adding a <base> tag for this, but it causes problems with other relative links on the site.
October 12th, 2011:
If you look at the raw source of the README.md of Markdown itself(!), relative paths don't seem to be supported.
You will find references like:
[r2h]: http://github.com/github/markup/tree/master/lib/github/commands/rest2html
[r2hc]: http://github.com/github/markup/tree/master/lib/github/markups.rb#L13
As noted in InvisibleWolf's answer, if the target link is a directory and it has space, then you need to use %20 for each space.
For example, you have a repo like the following:
project/
text.md
subpro/
subtext.md
subsubpro/
subsubtext.md
subsubpro2/
subsubtext2.md
The relative link to subtext.md in text.md might look like this:
[this subtext](subpro/subtext.md)
The relative link to subsubtext.md in text.md might look like this:
[this subsubtext](subpro/subsubpro/subsubtext.md)
The relative link to subtext.md in subsubtext.md might look like this:
[this subtext](../subtext.md)
The relative link to subsubtext2.md in subsubtext.md might look like this:
[this subsubtext2](../subsubpro2/subsubtext2.md)
The relative link to text.md in subsubtext.md might look like this:
[this text](../../text.md)
GitHub could make this a lot better with minimal work. Here is a work-around.
I think you want something more like
[Your Title](your-project-name/tree/master/your-subfolder)
or to point to the README itself
[README](your-project-name/blob/master/your-subfolder/README.md)
As of January 31, 2013 Github markdown supports relative links to files.
[a relative link](markdown_file.md)
However, there are a few deficiencies that have been discussed in this comment thread.
As an alternative, you can use Gitdown to construct full URLs to the repository and even make them branch aware, e.g.
{"gitdown": "gitinfo", "name": "url"} // https://github.com/gajus/gitdown
{"gitdown": "gitinfo", "name": "branch"} // master
Gitdown is a GitHub markdown preprocessor. It streamlines common tasks associated with maintaining a documentation page for a GitHub repository, e.g. generating table of contents, including variables, generating URLs and getting information about the repository itself at the time of processing the input. Gitdown seamlessly integrates with your building scripts.
I am the author of the Gitdown library.
Just wanted to add this because none of the above solutions worked if target link is directory with spaces in it's name. If target link is a directory and it has space then even escaping space with \ doesn't render the link on Github. Only solution worked for me is using %20 for each space.
e.g.: if directory structure is this
Top_dir
|-----README.md
|-----Cur_dir1
|----Dir A
|----README.md
|----Dir B
|----README.md
To make link to Dir A in README.md present in Top_dir you can do this:
[Dir 1](Cur_dir1/Dir%20A)
You can link to file, but not to folders, and keep in mind that, Github will add /blob/master/ before your relative link(and folders lacks that part so they cannot be linked, neither with HTML <a> tags or Markdown link).
So, if we have a file in myrepo/src/Test.java, it will have a url like:
https://github.com/WesternGun/myrepo/blob/master/src/Test.java
And to link it in the readme file, we can use:
[This is a link](src/Test.java)
or: This is a link.
(I guess, master represents the master branch and it differs when the file is in another branch.)
You can use relative URLs from the root of your repo with <a href="">. Assuming your repo is named testRel, put the following in testRel/README.md:
# My Project
is really really cool. My Project has a subdir named myLib, see below.
## myLib docs
see documentation:
* myLib/
* myLib/README.md
This question is pretty old, but it still seems important, as it isn't easy to put relative references from readme.md to wiki pages on Github.
I played around a little bit and this relative link seems to work pretty well:
[Your wiki page](../../wiki/your-wiki-page)
The two ../ will remove /blob/master/ and use your base as a starting point. I haven't tried this on other repositories than Github, though (there may be compatibility issues).
In .md file when you want to create a link to any related files which is related to same project folder or URL based links:
Existing file link:
In .md file add showing name in [] box then open () in this box add / after that it will auto fetch all existing folders name form which you choose your folder then add '/' it will show inner file or 'folders`. This means it will auto fetch the paths and at the end, your URL is created.
Example:
[Enter Showing Name](/users/4000266/heysushil)
This line show like this:
Enter Showing Name
Add URLs on .md file
Follow the same process only change the () box path with URL like this:
[HeySushil - YouTube](https://youtube.com/heysushil)
This looks like HeySushil - YouTube
Note: Remember no need to add force manually after adding / on () box it will auto fetch all existing folders and files.
I am not sure if I see this option here. You can just create a /folder in your repository and use it directly:
[a relative link](/folder/myrelativefile.md)
No blob or tree or repository name is needed, and it works like a charm.
If you want a relative link to your wiki page on GitHub, use this:
Read here: [Some other wiki page](path/to/some-other-wiki-page)
If you want a link to a file in the repository, let us say, to reference some header file, and the wiki page is at the root of the wiki, use this:
Read here: [myheader.h](../tree/master/path/to/myheader.h)
The rationale for the last is to skip the "/wiki" path with "../", and go to the master branch in the repository tree without specifying the repository name, that may change in the future.
The behaviour in Github directory links in markdown files could create some headaches.
All files have an url are starting with blob,
blob/<branch>/<path>/<fileName>
whereas directories have an url starting with tree:
tree/<branch>/<path>
So no relative link to a directory should work. It points to an url that starts with a blob. Magically Github changes some relative path automatically to the tree path. Unfortunately not urls containing ".."
I investigate some time to examine the strange behaviour with Github directory links on https://github.com/fluentcodes/GitSamples-GIT/tree/github-readme-links.
Just follow the format below.
[TEXT TO SHOW](actual URL to navigate)
Here is what I found for relative links in github's .md files:
Relative links without ../ (aka. link to file in the same level, or in sub dir), seems always work.
Relative links that contains ../ works only when you are already in a page whose url contains substring /blob/.
Otherwise need to use full url that contains /blob/, to link.
Actually except top level /README.md, when view any other files, their url already contains /blob/.
Thus probably you can always use relative links that contains ../ in files, except /README.md.
But /README.md is in top level, thus it shouldn't need a relative link that contains ../.
So, you should never need a full path link (that contains github domain) to link to files in the same github repo.
Example (links among multiple language doc)
In /README.md, can use relative links without ../.
[中文](doc/cn/README.md) |
[日本語](doc/jp/README.md)
In /doc/cn/README.md, since when we view it, the url already contains /blob/, thus could use relative links with ../.
[English](../../README.md) |
[日本語](../jp/README.md)
(BTW, the example come from this git-merge-flow repo.)
What I found to work for relative folders:
[link text](subfolder/subsubfolder/relevantfolder/)
where relevant folder is the folder you are trying to link to. The backslash is needed after the folder name. I tried including the project name and tree/main in the path and the other things suggested in previous answers, that lead to a nonexistent page error. The subfolder is a folder within the overall repo project folder.
Thus, file links would be in the form of:
[link text](subfolder/subsubfolder/relevantfolder/index.html)
If the desired file is not in any folder or subfolder the link is simply:
[link text](README.md)
for example the README file is not in any subfolders, so that could be the exact relative link you use for the README file.
You can also insert your links (relative or absolute) at the bottom to reduce clutter in text.
It can also be a good option for repetitive links.
This is [my linked text].
[my linked text]: relative/path/in/repo/to/file.txt "Optional title for mouse hover"
This is my linked text.