Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I create a download link in GitHub Markdown?

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"
like image 611
Aaron Avatar asked Sep 15 '25 15:09

Aaron


1 Answers

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 |
like image 65
Madhu Bhat Avatar answered Sep 17 '25 05:09

Madhu Bhat