Markdown Links: Inline, Reference and Relative Path Examples
Write Markdown links with working inline and reference examples. Fix relative paths, filenames with spaces and links that fail after pasting.
On this page
01Copy inline and reference links from one working example02Resolve relative links from the current file03Fix the symptom you can actually seeWrite a Markdown link as [text](destination), with no space between the closing bracket and opening parenthesis. Use a full https:// address for a public website. Use a relative path when the destination is another file in the same documentation project.
If a link looks right but opens the wrong page, separate two questions: did Markdown create a link, and does its destination point to the intended resource? A bracket typo is a syntax problem. A link that opens a missing file may have valid syntax and the wrong path. That distinction makes troubleshooting much faster.
This short document uses an inline link for the editor and reference links for two documentation pages. Paste the whole example, including the definitions at the bottom.
## Documentation shortcuts
- [Open the editor](https://markdowntoimage.com/converter "Markdown2Image editor")
- [Check GitHub formatting][formatting]
- [Read the link specification][syntax]
Keep this source beside the exported image.
[formatting]: https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax
[syntax]: https://spec.commonmark.org/0.31.2/#links
The first link includes an optional quoted title after the address. Its visible label remains “Open the editor”; the title is separate metadata. Put useful words in the label itself so a reader can decide where the link goes without relying on a tooltip.
Reference links move long addresses away from the list. The second bracket contains a label such as formatting, and the definition connects that label to a destination. Keep the definition in the same document. If you copy only the list into another file, copy its definitions too. Original Markdown link documentation
Choose inline links for a short note with a few destinations. Choose reference links when a long address interrupts the source or several labels reuse one destination. Before editing a shared definition, check where it is used: one change can update several links.
Imagine these three links are written in docs/guide.md. They are path examples, not files supplied by this article.
[Setup](./setup.md)
[Repository README](../README.md)
[Guide with a space in its name](./Setup%20guide.md)
The first points to docs/setup.md. The second goes up one directory to the repository's README.md. The third points to docs/Setup guide.md, with its space encoded as %20. Match the actual filename and capitalization rather than guessing from the page title.
On GitHub, relative links in a rendered file are resolved from that file, and links starting with / are relative to the repository root. GitHub also adapts them to the branch being viewed. That makes them useful within a repository. GitHub relative link guidance
When you paste the same source into a hosted editor or publish it on another website, its repository context does not travel with it. Check the resulting destination there. For a standalone announcement or image companion page, use public absolute addresses for resources readers need to open.
For a filename containing a space, encode that space as %20 in the destination, as the third path example shows. Do not replace spaces in the visible label: readable labels and URL paths serve different purposes.
If a destination contains parentheses, check that they are balanced or encoded appropriately. An unmatched closing parenthesis can end the destination earlier than you intended. Also check that a quoted title is separated from the address and properly closed. CommonMark link rules
Change one part at a time. First copy the intended address into the browser and confirm that you can open it. Then put it back into the smallest possible Markdown link. Add the descriptive label and optional title after that works. This isolates a bad destination from extra punctuation introduced during editing.
| Symptom | First check |
|---|---|
| The brackets appear as plain text | Remove a gap between ] and ( and check matching delimiters. |
| A reference link keeps its brackets | Find the corresponding label definition in the same document. |
| A website name opens under the current site | Add the intended https:// scheme to an external address. |
| A link works in a README but fails after pasting | Resolve the relative path in the new location or use a public absolute URL. |
| A filename containing spaces fails | Check %20, exact capitalization and whether the file exists. |
| A link appears correctly but opens an error page | Test the destination and its access permissions separately from Markdown syntax. |
Links to headings introduce another dependency: the destination renderer's heading anchors. When the broken link starts with #, copy the anchor from the rendered heading rather than inventing it. The Markdown table of contents guide covers that workflow and duplicate headings.
We entered the full example in the live Markdown2Image editor and checked all three generated destinations, the optional title and the hidden reference definitions. The PNG below was downloaded using the editor's normal image download control.
Use the image in a slide or documentation review to discuss the labels and layout. A PNG does not preserve clickable hyperlinks. Put the original document or a public destination link beside the image, and keep the Markdown source for the next revision. Before sharing, test the clickable companion link with the access your readers will have. Preview your Markdown links in Markdown2Image