Suggesting links based on content

Right now typing [[ brings up the link suggestions based on file names.
Would it be possible to suggest links based on the contents of the note? The format of the link doesn’t need to change, i.e. once the suggestion is selected, the link can be the file name or the header where the content is found.

This could be an alternative (for certain use cases) to the Block reference requests which works well with markdown files, albeit with a “broader” block definition.

If generating the suggestions inline using by typing [[ would be problematic for whatever reason, a different set of symbols (e.g. //, {{, etc.) or a new a command in the palette that searches for text, and returns a formatted link would also be a good-enough alternative.

14 Likes

I like this!

What about something like this? If after you typed [[ and the link suggestion popped up, there was a way (a hotkey maybe?) to invoke any of the search operators.

I like your idea of using different symbols too.

For example, if a note “Apple Recipes” had the text “muffins” in it:

  1. type [[ to start adding a link.
  2. hit that special hotkey (or type {{ instead like your suggestion)
  3. type content:muffins
  4. You see a result that looks similar to search
  5. Hit Enter, and it adds the link to the file, “[[Apple Recipes]]”.
2 Likes

I think this would definitely be useful! I think having both options (a “simpler”, just plain content suggestion) and a search-based suggestion would be great. I could see the first one being faster for linking ideas (just keep typing), while the second is much more powerful and could let you find suggestions based on any of the search operators letting you filter by multiple criteria, e.g. only files with certain tags, file names etc.

2 Likes

One of the things that I particularly like about Roam is that the choice of how to search for of thing is based on what type of double bracketing I use.

Double square brackets gets me “filenames” effectively. The titles of pages.

Double parents gets me a match based on the content of a given block. In the context of Obsidian, that would be the content of a given file.

Now, one of the things that I don’t like is that if we added the double parent syntax to Obsidian, things would get a lot more complicated when it comes to deciding how to render that content – but there’s an easy solution. Once it decides what file your linking to, make it a standard double square bracket link when you commit. Double open paren never actually makes its way into the text itself but just acts as a convenient interface shortcut to doing a search.

That could work out really well.

Absolutely! I didn’t include parens in my suggestion to leave that open in case Block-level references make it to the editor, but I think any set of symbols (or worst case scenario a command) to search content and insert links in the current accepted format would be sufficient.

1 Like

Great idea! Reminds me of this feature request I made
https://forum.obsidian.md/t/use-same-search-component-for-quick-switcher-and-link-auto-complete/706

3 Likes

You could also have an option to show the first few characters of the file/header when choosing a link.

@rigmarole should we close this? Obsidian Release v0.9.3 added the menu to copy results from search and Obsidian Release v0.9.5 (Insider build) added global search based on content

1 Like

Wow! I wasn’t expecting block linking. That’s pretty cool and a great implementation!

So… we can link to blocks now, but I still don’t see any way of just searching for content, and then linking to the note, rather than the specific block or heading.

For example, let’s say I mentioned “apples” in the note “Pie Recipes”. But I forgot where I had mentioned apples.

I still think it would be a great feature to be able to type [[, and invoke a way to search by content, start typing “apples”, find that “Pie Recipes” has apples in it, and then be able to choose and simply link to [[Pie Recipes]]. No block reference required in this case.

2 Likes

That’s true! The global search returns links at the block level

Absolutely agree! It would be helpful to populate link suggestions with a search by content. This also frees up the need to put meaningful (and sometimes long) filenames on notes just to make them locatable for link suggestions. By reducing the emphasis on filenames, it also makes note-taking more fluid (this reminds me of one of the great benefits of the famous Drafts). One can get straight into the body of a note and start writing content, without hassling with a title. In fact, title could just be an auto-populated date-time stamp.

3 Likes

+1
I’m very eager to see this feature implemented in Obsidian.