How do I create a download link in GitHub Markdown?

Viewed 1428

I want to use links in a markdown file that one click download an RPM file. When I click the link, the page opens on GitHub.

Here is what I tried:

| Package                                                                                                              | Summery                    |
| -------------------------------------------------------------------------------------------------------------------- | -------------------------- |
|  <a href="centos/8/x86_64/rpms/hello-2.10-1.el8.x86_64.rpm" download="hello-2.10-1.el8.rpm">hello-2.10-1.el8.rpm</a> | Hello, the rpm binary      |
|  <a href="centos/8/srpms/hello-2.10-1.el8.src.rpm" download="hello-2.10-1.el8.src.rpm">hello-2.10-1.el8.src.rpm</a>  | Hello, the rpm build files |

2nd

| Package                       | Summery                    |
| ----------------------------- | -------------------------- |
| [hello-2.10-1.el8.rpm][1]     | Hello, the rpm binary      |
| [hello-2.10-1.el8.src.rpm][2] | Hello, the rpm build files |

[1]: centos/8/x86_64/rpms/hello-2.10-1.el8.x86_64.rpm
[2]: centos/8/srpms/hello-2.10-1.el8.src.rpm"
2 Answers

In markdown links are shown like

[the text to be shown](https link)

so you can write it like

[hello-2.10-1.el8.rpm](https://github.com/joergklein/packages/raw/master/centos/8/x86_64/rpms/hello-2.10-1.el8.x86_64.rpm)

so as the .rpm can`t be open in the browser, they will be downloaded

And as you said it open the github page try to add https://raw.githubusercontent.com instead of https://github.com Then it will work

The relative link that you are using would resolve and redirect to the GitHub page of the particular file (note that it would redirect to ../blob/master/..). You need to add the markdown with the link for the raw file (so that it would redirect to ../raw/master/..) as below for it to be downloadable on click.

| Package                                                                                                              | Summary                    |
| -------------------------------------------------------------------------------------------------------------------- | -------------------------- |
|  <a id="raw-url" href="https://github.com/joergklein/packages/raw/master/centos/8/x86_64/rpms/hello-2.10-1.el8.x86_64.rpm">hello-2.10-1.el8.rpm</a> | Hello, the rpm binary      |
|  <a id="raw-url" href="https://github.com/joergklein/packages/raw/master/centos/8/srpms/hello-2.10-1.el8.src.rpm">hello-2.10-1.el8.src.rpm</a>  | Hello, the rpm build files |

Alternatively, you can also use the hyperlink markdown instead of html as below

| Package                                                                                                              | Summary                    |
| -------------------------------------------------------------------------------------------------------------------- | -------------------------- |
|  [hello-2.10-1.el8.rpm](https://github.com/joergklein/packages/raw/master/centos/8/x86_64/rpms/hello-2.10-1.el8.x86_64.rpm) | Hello, the rpm binary      |
|  [hello-2.10-1.el8.src.rpm](https://github.com/joergklein/packages/raw/master/centos/8/srpms/hello-2.10-1.el8.src.rpm)  | Hello, the rpm build files |
Related