Displaying a random quote in my daily note?

Things I have tried

I’ve been looking at Dataview, but it seems (I might be wrong!) that Dataview only works with full pages, and not with blocks? I was thinking of having a “Quotes” page, with different blocks, and was hoping to select a random one to be places in my daily note template.

Has anyone tried or achieved this?

I have a vague feeling that there is a plugin for this?

1 Like

I don’t think this is possible natively with any plugin. I’ve defined a very simple Powershell script which I can then call with a user-defined function in Templater:

$quotefile = 'location of file'
Get-Random -InputObject (Get-Content $quotefile)

The quote file is just a series of quotes in separate paragraphs (so you can’t have multi-paragraph quotes). No reason why the file can’t be in your Obsidian vault.

In Templater define a user defined system command function which points to the above script. I needed to keep the .ps1 extension:

Then in your template just reference the new function as:

<% tp.user.randomquote() %>

This seems to work for me. I’d obviously prefer a more native solution, especially since this won’t work when I’m on my mobile devices. But it might help someone else.

The Dice Roller plugin can do this. If you had a page with different quotes, where each quote was a block, e.g.:

Quotes.md

This is quote one.

This is quote two.

This is quote three.

…then you can use Dice Roller to display a random block from your quotes page:

MyPage.md (edit)

`dice: [[Quotes]]`

MyPage.md (preview)

This is quote two.
1 Like

Much better solution!