How to access the console out of templater script?

I want to debug a templater script, but I don’t know how to use the console and dev tools right, so I need a little advice on how to do that.

For example, I have a templater script, in which I write

console.log("hello world")

where do I have to look for the output - I cannot find it here:

Thanks in advance,

First of all, you have to use the <%* ... %> tags with the star after the first tag to allow JS execution. So having this template:

<%* console.log("hello world") %>

…you now have to execute your Templater code using the hotkey you assigned to it (or the “Replace templates in the active file” Obsidian command), then it’ll vanish and your DevTools Inspector console will show the message. Just tested it and the message shows up in a heartbeat.

Thank you for your quick response!

…Perhaps I should have formulated my questions more clearly. I outlined my use case for the templater script in this forum post:

My question mainly focuses on how to view the console output in the terminal…

Let’s consider this simple example: I have a note titled “templater test” containing only one line of code:

<%* console.log("hello world") %>

Then, I execute this templater script titled “templater test” within another note using the command “Open insert template modal.”

Where and how can I see the console output of “hello world”? I’ve only been able to see this (apologies, as I don’t have much experience using these development tools):

My setup when testing templates that I’ve got a file called xTemplate which is linked to Cmd + Ctrl + x. This template I then execute multiple times when testing in some log file.

If I add your code into this xTemplate file, and hit the hot key combination it shows as follows in the same place as from your screenshot:


If it doesn’t show there, then you’ve got something else disturbing the process. Like possibly something else causing Templater to bail out before reaching your debug statement. Note that this could be a failing Templater user script function.

But in general you should see the output in the window as you described, so it’s kind of strange that you don’t see it there.

hmmm… that’s strange…

After clearing everything from my console and then executing this templater script
<%* console.log("hello world") %>
I got these 6 error messages:


after jumping around in my vault, open some other notes, writing and so on, I constantly get new messages of the same typ…

… what is also strange: the templater plugin works usually in my setup. For example this code will be executed without errors (still I’ve got formating issues, but the script is executed correctly):

Do these error messages indicate, that there is something generally wrong in my Obsidian?

Try creating a new empty vault, install just the Templater plugin and see what happens then. If that works you’ve got some issue most likely with another plugin. If it doesn’t work, then either you’re doing something strange or there is something with your Obsidian installation.

What version of Obsidian and Templater are you on?

I tried it in the sandbox vault:

=> all good!

I disabled all my plugins and themes in my main vault and tried it: nothing, no console log…
I have the newest installer, see debug info:
Obsidian version: v1.5.0
Installer version: v1.4.13
Operating system: Windows 10 Pro 10.0.22621
Login status: logged in
Catalyst license: insider
Insider build toggle: on
Live preview: on
Base theme: dark
Community theme: none
Snippets enabled: 2
Restricted mode: off
Plugins installed: 60
Plugins enabled: 1
1: Templater v1.18.1

any further ideas?

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