Zettelkasten Forum


My first Obsidian plugin, link notes using IDs (link-as-search), feedback welcome!

Hi Zettelers! I wanted to share a ZK-related plugin I made for Obsidian that was partly prompted in response to Sascha's post, "The Hidden Problem with Note Titles as Links (And How to Fix It)".

The subject of the post is a technical discussion of how to link. In the post, Sascha argues why linking notes using unique IDs (UIDs) is preferable to having note titles function as link targets. The reasons he gives support why The Archive uses link-as-search over direct links. He also shows how aliases can provide a usable workaround in applications that don't support link-as-search, like Obsidian.

At the end of the post, @Sascha said:

"If you are an Obsidian power user, you can for sure write a small plugin that changes the linking mechanics by automating some of the steps to create a link alias."

This inspired me. I've been wanting link-as-search implemented as an option in Obsidian for a long time. Users have discussed/requested this feature previously (e.g., here, here, and here), but to no avail. The best workaround seemed to be aliases, like Sascha's suggestions.

I've actually just been using search to navigate my vault. That said, it would be even easier if I could alter Obsidian's default internal linking behavior to function as link-as-search. Then, I could navigate through my notes by clicking links, saving me about two mouse clicks and 6-8 keystrokes each time.

Compared to a lot of other plugins available for Obsidian, this seemed like an absurdly simple thing to implement---if you knew how to code. As it happened, I've been teaching myself more about coding recently, and I decided I finally had enough confidence to attempt this as my first plugin.

The plugin is called Link by ID, and the GitHub repository can be found here. It does what it says on the tin, i.e., the plugin enables linking notes using unique IDs by altering Obsidian's internal linking behavior to function as link-as-search.

I built in a few additional features that make life easier when using the plugin:

  • Page preview uses the same search logic, so hovering over links made using UIDs will display correctly.
  • There is a setting to toggle whether clicking on internal links opens the search panel, providing a similar way of viewing backlinks as in The Archive.
  • There is a setting to enable CSS that removes the dimmed appearance of all unresolved links, so links made using UIDs look identical to standard links.
  • There is a setting to enable a configurable link ID autocomplete suggester that you can use to search for notes and insert UIDs as links. There are options to configure the character sequence that actives the autocompletion, as well as specify the ID delimiter (the character(s) separating the ID from the rest of the filename) and position (whether the IDs are at the start or end of filenames).

I made a related post describing the plugin in the Obsidian forums here. You can also view the README file for the repository on GitHub here.

I still have to go through the steps to submit this plugin to be reviewed as an official community plugin. This means you'll have to install the plugin manually if you want to try it out. I describe how to do this in the related post I made in the Obsidian forums.

I mainly wanted to share this here to respond to the idea posed at the end of Sascha's newsletter, which helped inspired me, as well as to have an opportunity for early feedback, especially since I know there are several developers in this community with far more experienced than I have.

This is my first time doing anything like this, so feedback and comments are very welcome. I used this sample plugin template as a starting point, and went from there. I found this overview in the docs helpful. I also relied heavily on Google and LLMs for coding advice and suggestions.

I’ve only tested this plugin on macOS in small/medium sized vaults, so I’d love to hear how it works for other setups.

I'm very excited to be sharing this, and I hope others also find it useful.

Comments

  • I'm all in for installing and testing this. I followed your instructions, but the plugin will not activate.

    "You can visit the repository here, click the green “Code” dropdown button, click “Download ZIP”, unzip the file, navigate to your vault’s plugin folder (/your-vault/.obsidian/plugins/—you may have to unhide the /.obsidian/ folder), and move the unzipped obsidian-link-by-search folder inside the plugin folder."

    When I search for installed plugins in Obsidian, I get a list that includes "Link by ID" with your name attached. It will not allow me to enable it.

    When I compare the contents of the plugin folder with other folders in the .obsidian/plugins directory, I see that this folder doesn't contain a manifest.json or a main.js file.

    Am I missing something?

    Will Simpson
    My peak cognition is behind me. One day soon, I will read my last book, write my last note, eat my last meal, and kiss my sweetie for the last time.
    My Internet HomeMy Now Page

  • edited March 25

    When I first tried to enable the plugin, I got the error message in Obsidian's console, that there was no main.js. I had to run npm run build to make it work.

    When I click on an internal link, the search panel opens up and searches for the link text as expected!

    It does save one click compared to right-click on a text and choosing "Search for …". Not sure if it's worth the price of losing the functionality and speed of real links.

    I love such experiments. Thanks for trying!

  • edited March 26

    Thanks a lot @harr, doing the npm dance did the trick.
    @dylanjr, this plugin works great. It bring the link as search to Obsidian.
    This is lightning-fast for a vault with 4K notes and almost 2 GIG in the media folder.

    Zettelkasten Statistics

       ★★★★★ 
    

    1514243 Total word count
    21684 Total link count
    4434 Total zettel count
    ★★★★★

    I'm not sure what @harr means by "Not sure if it's worth the price of losing the functionality and speed of real links." I'm not sure what other functionality is being lost, and these are real links that resolve faster than my eyes can blink.

    Will Simpson
    My peak cognition is behind me. One day soon, I will read my last book, write my last note, eat my last meal, and kiss my sweetie for the last time.
    My Internet HomeMy Now Page

  • edited March 26

    @Will said:
    I'm not sure what other functionality is being lost

    For example that you can see at a glance, if a linked page exists or not. Or that a click on a link immediately opens the linked page instead of the search pane. Or that the backlinks plugin recognizes existing links. I work a lot with backlinks.

    I don't like that the plugin overrides a core mechanism. But that's the price. "Links as search" replaces links with search.

    Thanks again @dylanjr for writing the plugin. You gave us Obsidian users the opportunity to try out for ourselves. We can now test "links as search" with real data in our own vaults. Some won't like it, because they prefer Obsidian's way of doing things. Others will love it, because they prefer the other way of doing things. Your plugin gives us the choice. Thanks!

  • Thank you @Will and @harr for installing and testing my plugin and for your support and feedback! I'm elated to have members from this esteemed forum use a plugin I made for ZK :)

    @harr said:

    When I first tried to enable the plugin, I got the error message in Obsidian's console, that there was no main.js. I had to run npm run build to make it work.

    @Will said:

    [...] doing the npm dance did the trick.

    I'm glad you both figured out the workaround to install it manually. Being my first time developing a plugin, I'm not sure if I can fix that to avoid having to use npm run build, but I'll look into it.

    @Will said:

    This is lightning-fast for a vault with 4K notes and almost 2 GIG in the media folder.

    It's good to know that the plugin works fine on other systems, including for vaults the size (and strength) of @Will's.

    @harr said:

    It does save one click compared to right-click on a text and choosing "Search for …". Not sure if it's worth the price of losing the functionality and speed of real links.

    That's totally fair. I wish I would've known this workaround because it's definitely more efficient than what I was doing previously using key commands.

    @harr said:

    For example that you can see at a glance, if a linked page exists or not. Or that a click on a link immediately opens the linked page instead of the search pane. Or that the backlinks plugin recognizes existing links. I work a lot with backlinks.

    These are all really good points. I do think some of it comes down to design considerations in terms of link-as-search vs direct links. There are advantages and trade-offs for each.

    Using link-as-search means you can't tell visually whether a linked page exists or not (as far as I know?). In Obsidian, you can tell the difference visually because internal links to pages that don't exist, including links made using UIDs, appear dimmed compared to links pages that do exist (i.e., links where the link target matches the full filename or path of a file in the vault).

    That said, some of the features in the plugin settings try to address these limitations. There is a toggle to disable the dimmed effect of unresolved links. While this does mean that you can no longer tell the difference between links to pages that exist or not visually this way, hovering over links still works. This is because page preview uses the same search logic, so you can still use this as a visual cue to tell whether a linked page exists or not.

    Also, for backlinks, there is the option in the plugin settings to automatically open the search panel using the link target as the query, providing a similar way of viewing backlinks as in The Archive.

    I wonder if I can use the same search logic for the backlinks core plugin as well so that it works that way too...

    @harr said:

    I don't like that the plugin overrides a core mechanism. But that's the price. "Links as search" replaces links with search.
    Some won't like it, because they prefer Obsidian's way of doing things. Others will love it, because they prefer the other way of doing things. Your plugin gives us the choice. Thanks!

    I think this is the right way to view this plugin. Some will benefit from it because they prefer link-as-search, while it will be useless to others because they use direct links.

    But at least this plugin gives Obsidian users the option. Which for me is a good reason to go through the steps to finalize and submit it for review as an official community plugin.

    Excuse the long response. I wanted to address everything.

    Thanks again for both of your comments! They made my day :)

  • I tried your plugin @dylanjr, and this is fantastic! A missing link-as-search capability was my main blocker on trying out Obsidian.

    This might enable me to migrate from unmaintained sublimeless_zk on Windows when on my work computer.

    I too had to build with npm. Here are the detailed steps.

    1. Clone the plugin repo using git to a folder .obsidian/plugins/ within your Obsidian vault.
    2. npm install
    3. npm run build
    4. In Obsidian, go to Settings > Community Plugins, and refresh next to "Install Plugins".
    5. Flip the toggle next to "Link By ID" to on.
Sign In or Register to comment.