How do you include an asset download link in markdown?

23,909

Solution 1

It's the same as a link. [File Name](url). It works for me on Github pages' Jekyll implementation of markdown.

Solution 2

Try using inline HTML <a href="myFile.js" download>Click to Download</a>

Solution 3

On GitHub.com

The GitHub wiki site strips out the download attribute, so conventional approaches as mentioned before aren't going to work properly. However, I found the following will work:

<a id="raw-url" href="https://raw.githubusercontent.com/github-username/project/master/filename">Download FILE</a>

Replace 'github-username' with your git hub user name, obviously. Replace 'project' with project name, 'filename' with the actual file name. This also assumes the file is not in a sub folder. Also, notice, it is actually hosted on raw.githubusercontent.com.

However, due the difficulty, I'm almost wondering if the site was intentionally deterring such behavior.

Share:
23,909
ktouchie
Author by

ktouchie

Updated on April 29, 2020

Comments

  • ktouchie
    ktouchie about 4 years

    I have a small JavaScript file in assets that I'd like to link to as a direct download.

    The following link simply opens the file in the current tab:

    [myFile.js]({{file name='myFile.js'}})
    

    I'd like the file to actually download on clicking the link. Is that at all possible in markdown?

  • KTibow
    KTibow about 4 years
    You can also use relative links too, if you're in a README or something.
  • Kuba
    Kuba over 3 years
    It does not seem to work, neither with absolute nor with relative links. It just open a new tab with raw file contents.
  • Jahmic
    Jahmic over 3 years
    @Kuba I haven't checked recently, but I wouldn't be surprised if GitHub changed the functionality on the server.