Hook to a header or block in Obsidian

One thing that I would love to be able to do, is to Hook to a heading or block ref in a specific note, and not just the whole note. I am not too savvy to figure out all the nuances or blockers for this implementation. I know the Advanced Obsidian URI has the capability of generating a URI to open a note at the block or heading level. Just can’t quite figure out a work around with Hook. If anyone has a way, advice, or knowledge if this is even feasible that would be appreciated.



If you can copy a precise well-formed URL from obsidian, then you could Hook it to something else using:

But when you later invoke Hook again from the specific document you would presumably not see the other link, it would be asymmetric.

Can you post an example of what those advanced URI’s look like? Do those block URLs use customary # URL fragments?

The way I would try doing it is:

  1. Select the paragraph in Obsidian
  2. Edit the Hook script to:
    1. Copy the text
    2. Check if it starts with a run of #s
      1. If it does, form the Obsidian URI
      2. If not
        1. Check for a block identifier
          1. If not there, paste the paragraph with a new identifier
        2. form the Obsidian URI

Here is a feature request for copying Obsidian block links in the format of Obsidian URI:
Support copying block links in the format of Obsidian URI · Issue #9 · mgmeyers/obsidian-copy-block-link

The current version of this Obsidian plugin is able to conveniently copy block links from within Obsidian. If block/header links can be copied in the format of Obsidian URL, then they can used to hook to any items by using Hook.

I can right click to copy block link and Hook it to new file using Hook to copied link. However, when I invoke the copied link it just open the file and doesn’t navigate to block.
Here is the link to the Advanced URI plug-in.
Here are two examples from the GitHub.

Open heading “Goal” in “my-file.md” (Important: Without syntax, only Goal): obsidian://advanced-uri?vault=&filepath=my-file&heading=Goal

Open block-id “12345” in “my-file.md” (Important: Without syntax, only 12345): obsidian://advanced-uri?vault=&filepath=my-file&block=12345

With Hook version 3.3, it is possible to navigate to the desired/hooked block for me. The workflow is as follows:

  1. Generate an ID for a block manually or by using a plugin like mgmeyers/obsidian-copy-block-link: Get links to blocks and headings from Obsidian’s right click menu.
  2. Copy the Blcok ID into clipboard by using the corresponding command for Advanced URI or by adding the command to the right-click menu with kzhovn/obsidian-customizable-menu: This plugin allows you to add every command to Obsidian’s right-click context menu and add custom icons.
  3. Hook a desired file to the copied URI to the block

@LucB It would be great if the copied link can be somewhat improved by Hook, though. Specifically, if the file link is copied by using Hook in the format of the official Obsidian URI, a Markdown link would be generated. Therefore, it would great if the copied Block Link in the format of the Advanced URI plugin can be converted by Hook into something like [File#^blockid](obsidian://advanced-uri?vault=xx&filepath=yy.md&block=blockid), to reflect both the file name and Block ID.

1 Like