Skip to content

fix: resolve vault-root-relative wiki links#183

Open
jakobvongehlen wants to merge 1 commit intosecure-77:mainfrom
jakobvongehlen:fix/vault-root-relative-wiki-links
Open

fix: resolve vault-root-relative wiki links#183
jakobvongehlen wants to merge 1 commit intosecure-77:mainfrom
jakobvongehlen:fix/vault-root-relative-wiki-links

Conversation

@jakobvongehlen
Copy link
Copy Markdown

@jakobvongehlen jakobvongehlen commented May 3, 2026

Fix: vault-root-relative wiki links resolve from vault root, not current file directory

Problem

When a markdown file in a subdirectory (e.g. projects/my-project/notes.md) links to another file using a vault-root-relative path like [[references/arxiv-2507.21678]], Perlite was incorrectly resolving the link relative to the current file's directory, producing an incorrect path like projects/my-project/references/arxiv-2507.21678 instead of references/arxiv-2507.21678.

Root Cause

In PerliteParsedown.php, the safeLinkUri() method applies "current-file-relative" path stripping to all non-absolute links. This logic was designed for bare-filename links (e.g. [[other-note]]) but was incorrectly also running on vault-root-relative links.

Solution

Detect whether the link target contains a path separator (/). Only apply the current-file-relative resolution to bare filenames (no /). For vault-root-relative links (which contain /), reset the base path to '' so resolution starts from the vault root.

When niceLinks=true (default), [[category/name]] links were incorrectly
resolved relative to the current file's subdirectory instead of from
the vault root.

Before: [[references/arxiv-2507.21678]] from /projects/infosse
         resolved to 'projects/references/arxiv-2507.21678' (wrong)

After:  [[references/arxiv-2507.21678]] from /projects/infosse
        resolves to 'references/arxiv-2507.21678' (correct)

The fix adds a check: if the link already contains a path separator,
treat it as vault-root-relative and use an empty base path. Bare
filenames (no '/') continue to resolve from the current file's
subdirectory, preserving existing behavior for same-folder links.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant