avatarGareth Stretton


Obsidian: Use a Web Form Inside Obsidian to Update Frontmatter and Trigger Other Actions

This article shares how to create a web form inside of a note that can update frontmatter and trigger other Obsidian-related actions. Here’s a demo…

Demo Updating Frontmatter using a web form

To show that this is part of the note, below is an animated GIF toggling between ‘reading view’ and ‘source code’ mode.

How Does It Work?

A web form is added to the page. For example, below is the web form for ‘setting a property value’…

<form action="obsidian://advanced-uri" method="get">
 <input name="commandid" type="hidden" value="templater-obsidian:System/Templates/Runner.md"/>
 <input name="template" type="hidden" value="PropertyActions"/>
 <input name="targetNoteName" type="hidden" value="Property%20File"/>
 <input name="actionName" type="hidden" value="setProperty"/>
 <label for="propertyName">Property name:</label>
 <input name="propertyName" id="propertyName" type="text" value=""/><br/>
 <label for="propertyValue">Property value:</label>
 <input name="propertyValue" id="propertyValue" type="text" value=""/><br/>
 <button type="submit">Set Property Value</button>

The HTML above adds some visible UI elements to the page, i.e. a textbox for ‘Property Name’ and ‘Property Value’. Other fields are hidden and describe which…:

  • vault to interact with (vault)
  • note to edit (targetNote)
  • Obsidian action to execute (commandid)
  • template to run (template)
  • property-action to perform (actionName)

Together these values form an application URI that Obsidian will respond to. This process is described in detail in the previous article.

Just briefly,… this is what the generated URI looks like…


And this is the message flow…

Message Flow

Obsidian will ask the plugin ‘Obsidian Advanced URI’ (OA-URI) to execute a template, which will execute a ‘runner’ template, which itself will execute the target template (template=PropertyActions). The ‘runner template’ saves us from having to configure each template that we want to make accessible. The target template exposes general purpose operations that act on frontmatter properties (e.g. set, delete, add, remove).

Other Actions

This approach could be modified to trigger other Obsidian actions through your own web form. These actions can be simply, that is, those exposed by Obsidian and OA-URI plugin. (Skim-read what capabilities OA-URI has to offer!) Or they can be complex, that is, your own JavaScript which is run within a Templater template (perhaps leveraging Dataview too).

The alternative to this would be to ask the user for values through a series of prompts. Being able to create your own UI allows for more custom elements, e.g. descriptions, images, reference material, etc. All of which help in deciding what to enter. It’s possible that the UI could have dependent fields or draw values from sources outside of Obsidian.

Being able to create your own UI puts the power back in your hands. You are able to craft a solution that solves your problems.

Recap on Triggers

We now have 3 ways to trigger custom actions in Obsidian:

  • NEW: a custom UI
  • running a Template
  • an external application invoking a URI

Final thoughts

In other articles I’ve shared how to invoke system commands and web APIs. All of this combined greatly enhances your ability to extend Obsidian … without being overly reliant on plugins (…just a few core ones).

You are able to add those missing features today without waiting for the next official update. And if you externalize the logic it can be re-used across your other text editing applications (e.g. Neovim, or your favorite editor with CLI capabilities).

In the ideal world, all of the functionality would be inverted and externalized, and re-useable across applications — in keeping with the Unix Philosophy

Write programs that do one thing and do it well. Write programs to work together. Write programs to handle text streams, because that is a universal interface.

Sample Vault

If you want to download a ready-to-go sample vault, it can be purchased here for $1 or a donation of your choosing…

Download the Sample Vault for $1+

Note: If you previously purchased the ‘Obsidian: A Descriptive Approach’ then you have access to these changes and will keep receiving future updates.

Thank you for supporting my work!

Check out my other Obsidian Articles too.

Knowledge Management
Obsidian Templater
Recommended from ReadMedium