Markdown Toolbox Logo Markdown Toolbox
Home
Blog

How do I Link to a File in Markdown?

Friday, December 15, 2023

Linking to files in Markdown is similar to creating hyperlinks to web pages. You can link to local files, images, or documents hosted online.

To create a link to a file, use the standard Markdown link syntax, where the URL points to the file's location. The syntax is [Link Text](URL).

For a local file, the URL will be the file path, and for an online file, it will be the file's web address.

For example:

[Link to a local file](../../robots.txt)
[Link to an online file](https://www.markdowntoolbox.com/robots.txt)

This will render as:

Link to a local file Link to an online file

Ensure the file path is correct, and remember that linking to local files will only work if the Markdown file is being viewed in a context where the file path is accessible (like in a GitHub repository).