Markdown link to another markdown file

How to link one Markdown file to another: relative paths, links to headings, file names with spaces, reference-style links and how to check that every link works.

A link from one Markdown file to another uses the same syntax as any other Markdown link. The only difference is that the destination is a file path instead of a web address. This guide covers the basic form, relative paths, links to a section of another file, file names that contain spaces, and reference-style links. It ends with a checklist for testing the result.

What a file link does to your text

The input is a piece of link text in square brackets followed by a path in parentheses. When the file is rendered, readers see only the link text, and clicking it opens the target file, provided the platform displaying your files can resolve that path. In the raw source, the full syntax stays visible and unchanged. A link only points to the other file. It does not copy or embed that file's content, and it does not check that the file exists. A broken path still renders as a link that leads nowhere.

Basic syntax

[Installation guide](install.md)

In this example, the text inside the square brackets is what readers see. The text inside the parentheses is the path to the target file, and here it assumes install.md sits in the same folder as the file containing the link. Include the file extension exactly as it appears on disk.

Writing the path relative to the current file

Relative paths are resolved from the folder that contains the file with the link, not from the project root. Use a folder name followed by a slash to go down into a subfolder, and use ../ to go up one level. Take this example folder layout:

docs/
  index.md
  setup/
    install.md
  reference/
    api.md
Link is in | Target file | What to write
docs/index.md | docs/setup/install.md | Install
docs/setup/install.md | docs/index.md | Back to index
docs/setup/install.md | docs/reference/api.md | API

Use forward slashes, even when you edit on Windows. Treat file names as case-sensitive. Install.md and install.md are different files on many systems, so a link that works on one computer can break on another. A path that starts with a slash is interpreted differently from platform to platform, so relative paths are the more predictable choice.

Linking to a section in another file

[Configuration options](install.md#configuration-options)

The part after the # is a fragment that points to a heading in the target file. Each renderer generates heading IDs in its own way. A common convention lowercases the heading, replaces spaces with hyphens and drops most punctuation, but that is not guaranteed. The safest approach is to open the rendered target file, copy the link to the heading, and use its fragment.

Linking to a file with spaces in its name

In a standard inline link, a space ends the destination. A link written as [Notes](meeting notes.md) therefore does not render as a link in CommonMark-style parsers. There are two common fixes:

[Meeting notes](meeting%20notes.md)
[Meeting notes](<meeting notes.md>)

The first line percent-encodes each space as %20. The second wraps the path in angle brackets, which the CommonMark specification permits for destinations containing spaces. Older or non-CommonMark parsers may not support the angle-bracket form, so test it in the tool your readers use. If you can, renaming the file with hyphens, such as meeting-notes.md, avoids the problem altogether.

Two related pitfalls are worth knowing. First, parentheses in a file name can end the destination early, so escape them with a backslash or encode them as %28 and %29. Second, some characters look exactly like an ordinary space but are not one. A no-break space (U+00A0) is the usual culprit, and it often comes from copied text. A link typed with a regular space will not match a file whose name contains a no-break space. If a link looks correct but still fails, retype the space in both the file name and the link.

Reference-style links and converting to them

Reference-style links separate the link text from the path. You write a short label where the link appears and define the path once, usually at the bottom of the file. The definition lines do not appear in the rendered output. In CommonMark, label matching ignores letter case.

See the [installation guide][install] and the [API reference][api].

[install]: setup/install.md
[api]: <reference/api docs.md>

Converting inline links to reference style should change only the link syntax. Here is an illustrative before and after, not output from a specific tool:

Before:
Read the [installation guide](setup/install.md) first.

After:
Read the [installation guide][install] first.

[install]: setup/install.md

Whether you convert by hand or with a tool, check four things. The link text must stay exactly the same. The destination must be copied character for character, including any encoded spaces or fragments. Each label must be unique and must not clash with existing definitions. Finally, link-like text inside code spans and fenced code blocks must stay as it was, because it is example text, not a real link.

Step-by-step check

  • 1. Confirm the target file's exact name, including letter case and the .md extension.
  • 2. Write the path relative to the folder of the file that contains the link.
  • 3. Encode spaces as %20 or wrap the path in angle brackets.
  • 4. If you link to a heading, copy the fragment from the rendered target page.
  • 5. Preview the file in the same renderer your readers will use, and click every link.
  • 6. After you move or rename a file, search your project for the old path and update every link that uses it.

What depends on your platform

Some behavior is set by the platform, not by Markdown itself. Wiki-style links written in double square brackets are a feature of particular note-taking and wiki tools, not standard Markdown. Static site generators also differ in how they treat .md extensions when they build output pages. No platform-specific evidence was supplied for this guide, so it does not describe how any particular editor, repository host or site generator handles these cases. Check your tool's documentation and test in its preview.