Can I create a link that executes an Obsidian command?

I would like to create links that, when clicked, execute an Obsidian command (eg open today’s note, save to PDF, display the recent files list, etc.) I want this to be a single click on a link rather than having to type CTRL+P, find the command I want, then ENTER.

Somehow I thought Obsidian URIs would let me do this, ie

obsidian://execute?command=SaveToPDF

but that doesn’t seem to be supported. Is there any way to do this currently?

There is a plugin called “Buttons” that allows you to do exactly this:

It took me some experimentation and time with the docs to get it working.

To create a button that jumps to today’s page, I first defined a special block in a page that describes what the button should do:

```button
name Go to Today
type command
class button-as-link
action Daily notes: Open today's daily note
```
^button-open-today-page

Then elsewhere in my vault, I can place a link that when clicked, will execute the “Open today’s daily note” action:

`button-open-today-page`

To make the button look like a link, I included the following custom CSS:

button.button-as-link {
    display: inline-block;
    color: var(--text-accent);
    font-size: var(--editor-font-size);
    font-family: var(--default-font);
    background-color: #ffffff00;
    margin: 0em;
    padding: 0em;
    box-shadow: none;
    text-decoration: underline;
    cursor: pointer;
}

Hope this helps!

1 Like

Ah, I’ve used the Buttons plugin, but the CSS you gave is exactly what I need. Thank you.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.