Hi,
I started using Hookmark yesterday and am still integrating it into my workflow. I’m new to the community and hope this post fits the forum category.
My note-taking app is Obsidian, with several plugins—most importantly Templater. My goal was to apply a template to new notes created via Hookmark’s Hook to New feature, which doesn’t work by default.
In this post, I’ll outline the workflow I’ve set up so far (since I couldn’t find anything similar) and then ask a few questions. I’d appreciate any feedback or suggestions for improvement.
My solution:
I use two Obsidian plugins: Templater and Dataview.
Templater is set to trigger on new file creation and to apply a folder template for my default notes folder. However, folder templates only trigger when a note is created with an empty body. Hookmark’s New Item script creates notes with content (a Markdown link), so the template doesn’t run.
To fix this, I modified the New Item script to insert the link into the YAML frontmatter instead of the body. The note is now created empty, allowing the folder template to trigger. The template itself includes conditionals to detect whether the note was generated by Hookmark.
Using Dataview, I pull the link from the YAML back into the body dynamically. Alternatively, the link could be inserted statically via Templater, avoiding the extra plugin.
The setup supports all three URL schemes; I tested the default and advanced URI schemes.
My Questions
In my workflow I use Hook To New Obsidian and Copy Markdown Link very frequently.
- Is there an easy and suggested my to access
Hook to New Obsidianas a global shortcut, i.e. without opening the context window. - Is there a way to change the shortcut of
Copy Markdown Linkin the Hookmark Context Window. I think it would be cool if it was ⌃M - so I could press ⌃H ⌃M - Is there a way to change the shortcut of
Hook to New Obsidianin the Hookmark Context Window. I think it would be cool if it was ⌃N - so I could press ⌃H ⌃N
Technical Implementation
Obsidians New Item script:
Currently the new note is generated with this data:
[$title]($link)
After the change, the new note is generated with data:
---
hook: [$title]($link)
---
Changes for Advanced-URI URL scheme
Change from:
set myURL to "obsidian://advanced-uri?filename=" & encodedTitle & fileType & "&data=%5B" & encodedTitle & "%5D(" & encodedLink & ")&mode=new&x-success=" & callbackURL & "&x-error=" & callbackURLError
Change to:
set myURL to "obsidian://advanced-uri?filename=" & encodedTitle & fileType & "&data=%2D%2D%2D%0Ahook%3A%20%22%5B" & encodedTitle & "%5D(" & encodedLink & ")%22%0A%2D%2D%2D%0A&mode=new&x-success=" & callbackURL & "&x-error=" & callbackURLError
Changes for default and hookfiles URL scheme
Change from:
set myURL to "obsidian://new?name=" & encodedTitle & fileType & "&content=%5B" & encodedTitle & "%5D(" & encodedLink & ")&x-success=" & callbackURL & "&x-error=" & callbackURLError
Change to:
set myURL to "obsidian://new?name=" & encodedTitle & fileType & "&content=%2D%2D%2D%0Ahook%3A%20%22%5B" & encodedTitle & "%5D(" & encodedLink & ")%22%0A%2D%2D%2D%0A&x-success=" & callbackURL & "&x-error=" & callbackURLError
Folder Template Example
---
tags: <% tp.frontmatter.hook ? "\n - hookmark" : "" %>
description: <% tp.frontmatter.hook ? "Hookmark note for" : "no description" %>
---
**`=this.file.name`**
`=this.description`<%tp.frontmatter.hook ? " `=this.hook`" : "" %>
Further Remarks
I’m currently using the Advanced-URI scheme to keep notes movable and renameable. This adds two extra properties to my Hookmark notes (hook from the workaround and uid from Advanced-URI) that I usually don’t want to see. To hide them, I use the Metadata Hider plugin, which works flawlessly.
Discarded Idea
- I first tried to avoid modifying Hookmark’s
New Itemscript by adding a file-creation listener in Obsidian, but this proved more complex and fragile than adapting the Hookmark script directly. - Applying a template manually via an Obsidian shortcut also worked but required consistent manual effort and conflicted with my current Linter plugin setup.
For anyone experimenting with that approach, the following snippet might help:
<%*
var file = tp.app.workspace.getActiveFile()
var oldContent = await tp.app.vault.read(file)
await tp.app.vault.modify(file, "")
-%>
---
hook: |
<% oldContent %>
related:
tags:
- hookmark
topics:
aliases:
description: "hookmark note for"
---
**`=this.file.name`**
`=this.description` `=this.hook`