Why relative Markdown links break in Confluence, and how to keep them working

Updated 2 December 2026 · 7 min read

Short answer: Relative Markdown links break in Confluence because a path such as ../api/auth.md only means something inside a Git repository, while Confluence pages are addressed by a numeric page ID that does not exist until the page is created. The reliable fix is a two-pass import: create every page first, record each file's page URL, then rewrite every relative link to the matching Confluence URL. Anchors (#heading) and links to files outside the imported folder need extra care.

Why do relative Markdown links break in Confluence?

A relative link is a path that is resolved against the file that contains it. On GitHub, [Auth](../api/auth.md) works because the renderer knows where the current file sits in the repository. GitHub's documentation describes relative links as relative to the current file, with a leading / meaning the repository root.

Confluence has no files or folders. A Confluence Cloud page URL has the form /wiki/spaces/ENG/pages/123456789/Auth+Overview: a space key, a numeric page ID and the page title. Atlassian's documentation on heading links shows this pattern. Confluence assigns the page ID when it creates the page, so a Markdown file cannot contain it in advance.

When Markdown moves into Confluence unchanged, the link either survives as a path that points nowhere useful, or the converter drops the link and keeps only the text. Either way, readers lose the navigation that made the docs useful. Atlassian Community threads ask how to create pages from .md files and keep the relative links working, and why links in imported Markdown do not come through correctly.

Why does fixing relative links take two passes?

To rewrite [Auth](../api/auth.md), an importer needs the URL of the page that auth.md became, and that URL exists only after Confluence creates the page. Links that point forward or in a circle (page A links to B and B links back to A) rule out a single pass, because whichever page is created first links to a page that does not exist yet.

A two-pass import solves this:

  1. Pass 1, create the pages. Create every page in parent-before-child order with a placeholder body, and record a map from file path to page ID and URL.
  2. Pass 2, rewrite and publish. Convert each file's Markdown, replace every relative link with the URL from the map (keeping any #fragment), and update the page with its final content.
  3. Keep the map. Store the path-to-page-ID map so a later import updates the same pages. The rewritten URLs then stay valid across re-imports.

Open-source publishers use the same idea. md2conf, a Python tool, indexes the directory tree in directory mode and replaces each relative link with the Confluence URL of the referenced page. Its README says all relative links must point to Markdown files inside the directory hierarchy, and that single-file mode cannot resolve links to other pages. Folio for Confluence runs both passes on every import and stores the map per space.

Which relative link forms does an importer need to resolve?

Authors write relative links in more shapes than ./file.md. A resolver that handles only the simplest form leaves the rest as dead links.

Link as writtenWhat the resolver has to do
[Auth](./auth.md)Resolve against the folder of the current file
[API](../api/README.md)Collapse the .. segment, then look up the target file
[Home](/docs/index.md)Treat the leading / as the root of the imported folder
[Billing](../billing/) or [Billing](../billing)Map the folder to its README.md or index.md page
[Keys](auth.md#token-rotation)Resolve the page, then turn #token-rotation into that page's Confluence heading ID
[Keys](#token-rotation)Link to the current page's own URL plus its Confluence heading ID
[Notes](release%20notes.md)Decode %20 before the lookup
[Site](https://example.com)Leave unchanged

Folio's resolver covers each of these forms, and it falls back to a case-insensitive match when the exact case is not found, which helps with repositories written on case-insensitive file systems.

Root-relative links resolve against the folder you import, which may not be the repository root. If you import only docs/, a link such as /docs/auth.md points outside the import, so prefer ./ and ../ paths.

What happens to #anchor links after import?

GitHub builds heading anchors by lowercasing the heading, turning spaces into hyphens and removing most punctuation, so ## Token Rotation becomes #token-rotation and ## Rate Limits & Retries becomes #rate-limits--retries.

Confluence Cloud builds its heading IDs differently. It keeps the heading text as written, capitals and punctuation included, and turns each space into a hyphen, so the same headings become #Token-Rotation and #Rate-Limits-&-Retries. A repeated heading gets .1, .2 and so on. A GitHub-style fragment copied across unchanged therefore opens the page at the top instead of at the heading. Atlassian's documented way to get a heading link is to hover over the heading in the editor, select the link icon and copy the URL. A reported bug, CONFCLOUD-84442, also says that on some pages the anchors use a legacy PageTitle-HeadingName format (status unresolved as of December 2026).

A converter that knows the target page's headings can translate the fragment. Since version 3.11.0, Folio does: it reads the headings of the page a link points to and rewrites #token-rotation to #Token-Rotation, both within a page and between imported pages, and it numbers repeated headings the way Confluence does. A fragment that matches no heading is kept as written. After an import, click a few anchored links to check, especially on older pages affected by the bug above.

When a deep link must work, add an Anchor macro at the target in Confluence and link to it by name. Atlassian notes that anchor link names are case sensitive.

What happens to links that point outside the imported folder?

An importer can only rewrite links to files it has seen. A link to ../../other-repo/README.md, to a file you left out of the import, or to a page in another space has no entry in the map.

Folio keeps the link text, removes the dead link so readers do not click it, and flags the page with a warning in the import progress list. Absolute https links pass through unchanged. Two rules follow:

  • Import the whole tree in one run. The map is built from the pages in that run, so re-importing only a subfolder leaves links to pages outside it unresolved.
  • Use the full Confluence URL for other spaces. Confluence has no relative addressing between spaces. Copy the target page's URL, which contains its space key and page ID, and use it as an absolute link in the Markdown.

How do you write links that survive the move?

  • Use inline links, [text](path.md), where you can. Reference-style links ([text][ref] with a [ref]: path.md definition) also work in Folio 3.11.0 and later, but inline links are the most portable across tools.
  • Keep the .md extension and the real file name. Folder links work in Folio, but the explicit file name is the most portable form across tools.
  • Keep relative links relative. Do not swap them for absolute GitHub URLs, which would keep pointing at GitHub after the import.
  • Write descriptive link text. If a link cannot be resolved, the text is all that remains.
  • For navigation that must not fail, link to the page. Heading links work, but renaming a heading changes its anchor and breaks links to it.

How do you check links before and after an import?

Before importing, list every relative link to a Markdown file and confirm each target exists. This example command prints each match with its file and line number, and skips https links because they contain a colon:

grep -rnoE '\]\([^)#: ]+\.md(#[^) ]*)?\)' docs/

After importing, open several pages and click through, including at least one link that uses ../ and one that uses an anchor. Confluence Cloud has no built-in broken-link report. A public suggestion, CONFCLOUD-65867, asks for a link validator and was still open as of December 2026.

With Folio, the steps are:

  1. Open Space apps → Folio for Confluence in the target space and choose the Import tab.
  2. Drop in the Markdown folder or .zip, review the page-tree preview and choose a parent page.
  3. Import. Folio creates the pages in pass 1, then rewrites relative links and publishes the final content in pass 2.
  4. Open the Audit & fix tab and check Link integrity (25 of the 100 Context Health Score points). It flags broken internal links to missing or deleted pages, leftover raw .md paths, and localhost or placeholder URLs.

FAQ

Do relative links keep working if I import the same folder again?

Yes. Folio keeps a per-space map from file paths to page IDs, so a re-import updates the same pages in place and rewrites the links again. The page IDs stay the same, so the rewritten URLs keep pointing at the right pages.

What happens to relative links to PDFs, scripts or images?

Folio resolves links to Markdown files and folders only. A relative link to another file type keeps its link text but loses the link, and Markdown images become [Image: alt] placeholders because Folio does not convert images yet. Attach the file in Confluence and add the link by hand.

Should I replace relative links with absolute GitHub URLs before importing?

No. An absolute GitHub URL is an external link, so after the import it still points at GitHub instead of the Confluence page. Keep relative paths in the source and let the importer rewrite them.

How can I test link rewriting without touching a real space?

Create a scratch space, import a copy of the folder there, click through the pages, and delete the space afterwards. Folio's Import tab can also load an 8-page sample handbook if you only want to see how the import behaves.