48 - Better Path Handling

⚠️ This proposal is currently a draft and is not yet finalized.

Goals

Better path handling for links to regular files inside of Dendron

Context

The path handling today isn't portable or intuitive in a multi-vault setting

File Layout

This file layout will be used for subsequent examples

- root/ 
  - dendron.yml
  - notes/
    - root.md
    - note.md
  - a/
    - dendron.yml
    - notes/
        - root.md
        - note.md
  - b/
    - dendron.yml
    - notes/
        - root.md
        - note.md
  - c/
    - dendron.yml
    - notes/
        - root.md
        - note.md

Legend

  • AP: absolute path
  • RP: relative path

Current Behavior

Both absolute and relative paths are anchored to the directory where the topmost dendron.yml resides in. The downsides of this approach is that links inside of sub-vaults are not portable because they depend on a specific workspace configuration. The relative path behavior is also not intuitive as it is not relative to the note but relative to the vault.

  • from root/notes/root.md

    • AP: [[/dendron.yml]]: root/dendron.yml
    • RP: [[./dendron.yml]]: dendron.yml
  • from root/a/notes/root.md

    • AP: [[/dendron.yml]]: root/dendron.yml
    • RP: [[./dendron.yml]]: dendron.yml

Proposal

  • absolut paths should be relative to the vault that they belong in. This should be similar to the path handling from vscode.
  • relative paths should be relative to the file.

Example

Given the same file layout as the previous example, paths should resolve as follows:

  • from root/notes/root.md

    • AP: [[/dendron.yml]]: root/dendron.yml
    • RP: [[./dendron.yml]]: notes/dendorn.yml (this would point to a non-existing file because there is no dendron.yml file in notes)
  • from root/a/notes/root.md

    • AP: [[/dendron.yml]]: root/a/dendron.yml
    • RP: [[./dendron.yml]]: dendron.yml (invalid link, similar to the above)

Tradeoffs

The treatment of relative paths might still be easier to use if it were relative to the directory where the dendron.yml of the given vault was (same treatment as the absolute path). This is because linked to files are most likely going to lie outside of the notes folder which means most relative links will start with ../ to go outside of the notes folder.

Discussion

https://github.com/dendronhq/dendron/discussions/3506


Children
  1. Context