Send to Obsidian — with tags and YAML metadata

I’ve just added an improved version of a “Send to Obsidian” action. The improvements:

  • The note’s name is either the heading or the creation date-time, depending on the drafts beginning with a header or not.
  • A YAML header is added with the creation date and time of the draft.
  • The tags are written at the end of the note, under a separator line.
  • The vault name is an editable constant.

In practice :

  • If you start your draft with a #, it implies that the first line is a header — it doesn’t matter how many # there are.

    • In this case, the filename of the Obsidian note is derived from the header.
  • If the first caracter of the draft is NOT a #, the first line won’t be the note’s filename. Instead, the filename will be the creation date and time of the draft, in ISO format.

In any case :

  • A YAML metadata header is added at the top of the note, with an entry with the creation date and time of the draft.
  • The draft tags are added at the bottom of the note, below a separator line.

In the Directory, the action is → here ← .

Olivier Spinnler

6 Likes

Very nice.
You have couple of design decisions I’d like to understand the why of:

  • Why add the metadata front matter to the Drafts content? Doesn’t that muddy up the display title?
  • Why not put the tags in the metadata instead of appending to the end?

Being somewhat new to both Drafts and Obsidian, I may not be aware of legacy or best practices which might explain these practices.

Are you suggesting skipping the metadata? If not then the metadata has to go at the front.

The meta data is generated from the draft. It has to go at the front of the Obsidian note, but it doesn’t have to go at the start of the draft; but the action looks like it probably modifies the draft too.

In Obsidian, it’s own default tagging approch is to include hashes terms in the body. These hyperlink to a tag search. Meta data for tags in the YAML do the same, but when you search you don’t see them in context in the results. I think that can add value, but adding them to the end vs adding them to YAML at the start I don’t think offers any difference, other than meta data can be hidden, and I don’t think would appear if published - but I don’t use the publishing service, so I don’t know for sure.

Are you suggesting skipping the metadata?

No, I’m suggesting the front matter goes only to the Obsidian side of things leaving the Draft side unaltered. Sorry for not being clear on that.

the metadata has to go at the front.

Yes, in the Obsidian note, probably not in the draft. In the draft this metadata has no value I know of. Do I have that wrong?

1 Like

Yes, if the #tag #list is added to the end of the document the placement context is effectively lost. In that case it seems desirable to put those tags in the metadata where they can be hidden. This could also be used in some automated Obsidian to PDF action.

That’s correct: In the draft it has no value - as Drafts doesn’t do anything with it (including when rendering). Other Markdown processors, however, might well do.

Sorry to be a dumbo … new to obsidian … not new to drafts and have edited action steps in the past - but for life of me can’t get this to work.

What are the variables I need to change to make this work?

Thankyou in anticipation.

Looks like it should just be vaultName. It is using thr Obsidian URL scheme, and so just needs the vault name registered in Obsidian to be able to match to.

Thankyou - yes I thought that and it just wouldn’t play nice. But with your thought I kept modifying and found the error … the credentials were hanging around from an earlier experiment - now working.

Much appreciatrd

Paging @OlivierPS

Thankyou for this - very nice. I haven’t playing around a bit and very much living what I find. Sometime tho I have noticed that the action ‘stops working’ …

I repost the same draft just to experiment ,

In drafts it is as if once a draft is posted - it won’t post again?

But if I reset the draft it is all ok again.

Is that correct behaviour? I can understand why - just wondering

If you post with a level 1 heading draft as the title it will recreate the same file. If no such heading is present it will post with a timestamp as the file name. The timestamp is down to the second, so for a single draft I think you would alway get a unique file name and thus a new file.

Does that explain the behaviour you see? If not, can you provide more detail on the behaviour you see?

How do you “reset” your draft?

should be better - essentially copy the whole thing into a new note

i have pushed and prompted and persevered - and getting there. it still seems that SOMETIMES - if there i no header - the draft doesn’t post to obsidian - but not always - sometimes as you say - a tie stamp is there … i cat get anything repeatable right now though.

When i do i wil be back - my thank for your help