How does the attachment search work?

I’m wondering how attachment searches for images. I notice that when I move a note, the link doesn’t break, which is cool. But is there hierarchy of where images are searched for? Like first in the current folder, then in subfolders then in whole Vault, or something like that?

Moved to Help.

It uses the shortest possible name. As long as an image or a note is in your vault, you can link directly to the name. That’s why links don’t break when you move.

In settings you can change how links get made, so it includes a path. In that case, if you moved an image or a note, the link would be updated to include the new path. If you edited the location externally, the link would break.

Your actual question was how does it search. I don’t personally know but:

If you have two notes or images with the same name, then I don’t actually know what algorithm is used, but a link to just the name will match the first one it finds. To specify the correct one, you’d need to include either “Shortest Path when Possible” or “Relative Path to Vault” or “Absolute Path to Vault”.

Changing those settings won’t change existing links. It only changes how new links get formed.

I tested embedding a note with a duplicate name, linked only to ![[Note Name]]. And then in an external folder, I moved the note into a deeper folder. The embed changed to pointing to the one in a shallower folder first. But that might have been a coincidence.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.