Using Hook with Obsidian

This document assumes you are using Hook 3.5 (or newer) and Obsidian O.14.16 or newer. If you are still using Hook 3.4.3, please refer to Using Hook 3.4.3 with Obsidian.

Obsidian is an electron-based note-taking app that treats links as first class data objects. It is “a powerful knowledge base that works on top of a local folder of plain text Markdown files.”

With Hook, you can easily link your Obsidian notes to just about anything. Not just to other Obsidian notes, but to emails, web pages, and more. Plus, Hook provides a native Mac user interface experience to linking Obsidian information. With Hook, you can use the same familiar interactions across all your favorite apps, including Obsidian.

Hook enables you to choose one of three different URL schemes for Obsidian (default, “advanced” URI, hook file). The default option is available ‘out of the box’, whereas the other two require a bit more configuration. There are trade-offs between each approach. In addition, of course, Pro users can customize Hook’s integration with Obsidian using Hook’s Script Editor.

Using the default integration between Hook and Obsidian

When you use the default integration with Obsidian, Hook’s Copy Link and Copy Markdown Link will return obsidian:// links. When you hook items together, using menu bar icon or Hook’s contextual popup window, Hook will also use obsidian:// links for the note.

For most people this will be sufficient.

Summary of tradeoffs between URL schemes

Feature default “advanced URI” hook://file/
Avoids needing to install advanced plugin x
Avoids needing to change a Hook Preference x x
Supports Hook to New > Obsidian
Supports Hook’s Reveal File in Finder x x
Opens links/hooks directly in obsidian x (in default app or Finder)
Can move files in same vault x
can move the file to a different vault, or anywhere on your Mac, and the links will still work x x
If you switch away from Obsidian to a different app, your links will still work x x
Avoids adding info to the body of the note file x

Benefits of the default integration with Obsidian

  • Works outside the box, no configuration of Obsidian or Hook required
  • works with Hook menu bar icon (not the case for the “advanced URI” or “hook file” integration with Obsidian
  • links generated by Hook can be used across devices even without Hook (e.g., on Windows or iPhone), as long as you sync your obsidian files properly.

Limitations of default integration with Obsidian

There are some limitations to the default integration which are due to the fact that Obsidian is an electron app that lacks a built-in API that Hook can use to get the file path and name of the current note, and to create new notes. With the default integration,

  1. You won’t be able to use Hook’s Reveal File in Finder feature in Obsidian. You’ll need to use Obsidian’s UI which it calls (Show in system explorer) or a custom keyboard shortcut in Obsidian.
  2. If you rename files or moved them to a different vault, Obsidian links break.
  3. If you migrate from Obsidian to a different note-taking app, you won’t be able to use your (obsidian://) links.

NB:

  • You can overcome limitation 2 by using the the advanced URI scheme described in next section, or by using the hook file (hook://file/) integration scheme.
  • You can overcome limitations 1, 2 and and 3 by using the hook file (hook://file/) integration schemes.

Using the “Advanced URI” integration between Hook and Obsidian

There is a free Obsidian community plugin integration called “Advanced URI” made by Vinzent. This plugin provides a number of useful functions. The main effect of this plugin is to change the URI scheme of notes within Obsidian itself to obsidian://advanced-uri. The main benefit of this plugin compared with the default is that, whether you use Hook or not, links created with it are robust, meaning you can move the notes around within the same vault (not between vaults, let alone outside Obsidian) and the links will still work. The table above lists the other benefits.

This plugin works by adding an ID to any Obsidian file to which it generates links. For example, it may add the following to top of the file:

---
id: 2d73ce68-9e27-4463-8d21-443bc4a9cb02
---

When you create a link with this plugin installed, the link’s address (URL) includes the ID of the file. An example is obsidian://advanced-uri?vault=myVault&uid=2d73ce68-9e27-4463-8d21-443bc4a9cb02 . Notice the “UID” field. (The “UID” keyword is configurable in the plugin’s settings).

If you would like Hook to use the “advanced URI” integration, you’ll need to:

  1. install the “advanced URI” plugin from within the Obsidian app. Search for “Advanced URI” in the community plugin browser interface. See Plugins mini FAQ – FAQ – Obsidian Forum.
  2. enable Use UID instead of file paths in the Advanced URI plugin’s settings. To get there, you can use the gear menu at the bottom right of the plugin’s UI. Or click on Obsidian > Settings > Advanced URI. You can also configure the UID field in frontmatter field (e.g., with ui or uid.
  3. issue the following command from the /Applications/Utilities/Terminal app :

defaults write com.cogsciapps.hook integration.obsidian.URL.scheme obsidian-advanced-URI

To learn more about this plugin, visit Vinzent03/obsidian-advanced-uri: Advanced modes for Obsidian URI.

If you configure Hook to use the Advanced URI integration scheme with Hook, then whenever you link items with Hook (whether via Copy Link, Copy Markdown Link, or Hook to New) then the links created will be of the form obsidian://advanced-uri.


How to switch between integration schemes

Using /Applications/Utilities/Terminal you can manipulate the URL scheme (“integration.obsidian.URL.scheme”) used by Hook with Obsidian.

  • defaults write com.cogsciapps.hook integration.obsidian.URL.scheme obsidian-default
  • defaults write com.cogsciapps.hook integration.obsidian.URL.scheme obsidian-advanced-URI
  • defaults write com.cogsciapps.hook integration.obsidian.URL.scheme hook-file

Using the hook://file/ URL scheme with Obsidian

To use the hook://file/ URL scheme with Obsidian you simply need to do this from the command line:

defaults write com.cogsciapps.hook integration.obsidian.URL.scheme hook-file.

Advantages of hook://file/ scheme over the advanced URI scheme (and the default):

  1. you can move the file to a different vault, and anywhere on our Mac, and the hooks will still be there. In fact, all your hook://file/ links should track the file.
  2. Reveal File in Finder works.
  3. If you switch away from Obsidian, your links will still work.

Disadvantage of hook://file/ scheme in Obsidian: hook://file/ links cannot be opened directly in Obsidian. They will open in the default app or be revealed in the Finder.

“Can I switch integration schemes later?”

The links generated by Copy Link and Copy Markdown Link will continue to work even if you switch schemes.

However, for any given Obsidian note, you will not see any “hook” (in hook window) that was associated with this note if it was generated when a different scheme was in place. (That’s because hooks are based on URI address of the item). If you change back to the other scheme, the hooks will appear again. Regardless, you should be able to find the link in Hook’s search, which is context agnostic.

Other information

Forum discussion

See Link Obsidian with AdvancedURI Plugin – Discussion & Help – Hook Productivity Forum for the discussion that led to the advanced URI integration.

There are other discussions Obsidian on the Hook Productivity Forum

Customer support for Obsidian integration

Please note that the “advanced URI” plugin is created by a third-party developer. CogSci Apps Corp. is not responsible for it and may not necessarily provide support for it. You should direct your questions about it to the Obsidian forum or Hook forum.

Default Obsidian integration is also limited due to the fact that Obsidian’s linking API does not meet the requirements of the Manifesto for Ubiquitous Linking, as noted above.

Gratitude