Fractal32 downloadsUses relative wikilink paths instead of absolute paths when filenames conflict.
An extremely lightweight Obsidian plugin that makes [[wikilinks]] cleaner.
Disclaimer: This plugin is meant to work with the setting "Files and links > New link format" set to
Shortest path when possible. If you do not use that setting, turn this plugin off. It won't break, but it will have confusing behavior.
Normally, when you create a wikilink in obsidian, it shows up as just the note name. (e.g. [[notes]])
But what if you create a wikilink to notes, but you have 2 or more notes of the same name? In that case, Obsidian creates a direct path, which looks something like this: [[work/summer/meetings/notes]]
This is fine and all, but having an entire long path in your link is inconvenient when the note you are referencing is right next to the active note.
This plugin fixes that. It changes Obsidian's behavior so that when a wikilink has no conflicting names, it stays nice and clean with a single [[name]], and when there IS a conflict, it replaces it using a relative path instead of a direct path, which looks something more like this: [[../meetings/notes]], and the path gets shorter the closer together the notes are. (e.g. [[./notes]] for a note in the same folder)
If the relative path backs up all the way to the main vault anyways, (e.g. [[../../../schedule/dinner]]) it uses a normal direct path instead to be cleaner. ([[schedule/dinner]])
[[notes]][[work/summer/meetings/notes]][[notes]][[./notes]][[./meetings/notes]][[../../notes]][[vacations/notes]]Note: There IS a existing setting called
Path from current fileunder "Files and links > New link format", but that applys to every link, so you get things like[[../../contacts/john]], even if you only have 1 note calledjohnin your entire vault.This plugin keeps the default
[[document]]formatting when possible, keeping your links nice and tidy.
Usage is very simple, install the plugin on Obsidian, make sure the setting "Files and links > New link format" set to Shortest path when possible, and you're set.
Creating new [[wikilinks]] now uses the behavior mentioned above.
Disabling the plugin will revert the behavior back to default, but please keep in mind that this plugin does not modify any existing wikilinks.
Note: This plugin only creates native Obsidian wikilink formats, so all links will still work perfectly if you remove the plugin.