How to make a download link in GitHub README.md file? - github

I uploaded a .epub file to the GitHub repository. I want to create a download link to this file inside the README.md file.
By clicking this link user will be able to download the file directly, without going to another page and clicking the download button on that page.
Is it possible to achieve this with the default README.md (markdown) file?

In text comes e.g. "click me" and at link just your downloadlink
You can do it with this:
[text](link)
as an example:
[click me to download](https://github.com/Schecher1/Minecraft-Server-Creator/blob/master/README.md)

I was able to achieve the download link by putting my .epub file inside a release assets.
After creating a release I right-clicked on the artifact and copied the link address.
The markdown snippet looks like this
[epub](https://github.com/name/project/releases/download/v1.0.0/book.epub)
It immediately starts loading the file upon clicking the epub word.

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!

How to host image at https://user-images.githubusercontent.com/{path}/{filename}?

I'm a developer, I need many screenshots to put in readme.md file where to store or host it? I found out that some people use https://user-images.githubusercontent.com/{path}/{filename} to host their image and link them with readme.md file. How to put images there??
You can create a .github/images directory in your repo and add all your assets there.
Assets added here will be available on
https://raw.githubusercontent.com/{github_user_name}/{repo_name}/{branch}/.github/images/{asset_name}.{asset_extension}
Once you push .github/images directory to remote your assets should be available through the mentioned link.
And https://user-images.githubusercontent.com/ is used by GitHub to store images added in issues, PR's, etc.,
Hope it helps!
UPDATE:
You can also create an assets directory in the root of your repo and use a relative path to the image.
/assets/{asset_name}.{asset_extension}
![Alt Text](/assets/{asset_name}.{asset_extension})
With this, images can be previewed without actually pushing to remote.
Hosting on user-images.githubusercontent.com subdomain
If you do not intend to store any images in your repository, you can always use this https://user-images.githubusercontent.com/
To host your images in user-images subdomain you can do the following
Click New Issue this will open up the issue creator.
Drag and Drop or Upload your image in the body content
Wait for upload completion and copy the URL for the image.
Cancel the issue creation and continue.
But you will not have access to these images once uploaded, you cannot delete them. You can always contact GitHub Support if required to delete.
Just drag and drop your image from your local pc to github readme in editable mode.
I took a screenshot of a diagram and tried to paste it directly into a comment in GitHub and it was automatically uploaded to "https://user-images.githubusercontent.com/" and embedded as a markdown tag. Then I tried to paste the same tag into a readme.MD with the same link and worked for me.
When you are editing the readme file on github, you have to drag the file you want to add in this specific box. That worked for me. If I dropped it anywhere else, it wouldn't load.
While editing readme.md in GitHub UI, paste the image from the clipboard directly in the readme, and the image is automatically uploaded into user-images.gitHubusercontent, and the link is updated in the readme to show the image.
To add or store them just open the issues click on new issue and drag and drop your desired image in comment section and wait for it to upload in user-images.gitHubusercontent. when its done just copy that and paste it to your README.md file
You can simply put the file where you want it in yours repository, click on the file from the github.com page and left click the Raw button or right click Download button and select Copy link address. It will show the full path url, then you can just put it into any Markdown text.

Download link in GitHub markdown [duplicate]

When you link to a PDF file using:
[download this](file.pdf)
it downloads the pdf file. I have an excel workbook that I'd like to allow someone to download using:
[download this](file.xlsx)
When I click it, it takes me to create a new page in the wiki. Is there any markdown syntax I can add that identifies the link as something to download?
If I have to, I can save the excel workbook as a PDF, but it's not going to be pretty.
Thank you!
First, try making a files subdirectory in your wiki, and putting your files in there.
I tried using an html anchor tag
download this
instead of the markdown link syntax
[download this](files/file.csv)
but it seems that GitHub wiki strips out the download attribute from the anchor tag.
In the end, I zipped my spreadsheet in a zip file and had the markdown link point to the zip file.
[download this](files/file.csv.zip)

Can I link to a file for downloading (other than PDF) in a GitHub wiki?

When you link to a PDF file using:
[download this](file.pdf)
it downloads the pdf file. I have an excel workbook that I'd like to allow someone to download using:
[download this](file.xlsx)
When I click it, it takes me to create a new page in the wiki. Is there any markdown syntax I can add that identifies the link as something to download?
If I have to, I can save the excel workbook as a PDF, but it's not going to be pretty.
Thank you!
First, try making a files subdirectory in your wiki, and putting your files in there.
I tried using an html anchor tag
download this
instead of the markdown link syntax
[download this](files/file.csv)
but it seems that GitHub wiki strips out the download attribute from the anchor tag.
In the end, I zipped my spreadsheet in a zip file and had the markdown link point to the zip file.
[download this](files/file.csv.zip)

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>