Export to Markdown with Keywords / Hashtags?

I each of my documents are essentially cards - they have a name, some text, and have Keywords attached. I know how to export these “cards” as .md which I then import into Obsidian, which turns them into individual notes. BUT I want my cards to have the keywords included in the text, and have a # in front of the keyword so it is now a hashtag searchable and linkable to other cards in Obsidian.
Is there a way to export to to .md files and include their keywords?

In the export dialog, if you check the “Metadata” box, an additional file is generated (like “yourcard MetaData.txt”). Containing keywords, label, status, etc. for that document(s). That’s how you export it.

But then you have to process two files when importing. Not sure if you feel comfortable doing that.

Probably more useful would be to compile the output instead of exporting. So you could use the <$keywords> placeholder to get the assosociated keywords IN the compiled Markdown documents. *

* Works best when your keywords are already named #keywords with a hashtag in front of them in Scrivener.

Actually, now that I think of it, you don’t even have to use the <$keywords> placeholder, you can just check “Metadata” in the compile format:

Which inserts this into the output file:

	Keywords:	#tag1, #tag2, #tag3

I was able to do as you describe in the first paragraph.
And you are correct - I don’t know how to integrate the two files.
I don’t understand what you mean by "So you could use the <$keywords> placeholder to get the assosociated keywords IN the compiled Markdown documents. "
You also suggested to redo all my hashtags and place # in front of them?
Finally, when I try to compile the document as a “Basic Multimarkdown” (is that correct?) it creates one large .md file, not individual .md files/cards.
I do not get the option of checking the metadata box - how do you get that window?
Thanks in advance.


You could write <$keywords> in your documents, and after compiling the keywords would show up in this exact place. But I was faster typing than thinking, it’s unnecessary work.

Yes. Maybe there is a better way of doing this, but I can’t think of any (overly complex). [2] If you need 'em as #hashtag, so Obsidian recognizes them immediately, you might as well just enter them this way to begin with.

Interesting question. I never attempted to do that and I can’t find an option to do it. :thinking: [1] But yes, just “MultiMarkdown”.

Double-click your format (left side panel “Formats”) in the main Compile window. This should catapult you right into the section layout settings (shown in my previous screenshot).

[1] But you can easily split the compiled file later, e.g. the default delimiter between your notes (documents) there is “----” on a line on its own. So, in Terminal, executing this with your compiled.md as input:

awk '/^----$/{n++}{f = n ".md"; print > f}' compiled.md

splits it into 1.md, 2.md, 3.md etc.

[2] Okay, after giving it some thought, I actually can think of a better way: Instead of including all Metadata for a document (remember, that checkbox), you could also enter a Prefix for the section, generating YAML like this:

tags: <$keywords>

I think this is beyond me. Unfortunately, I am new here and can’t include screenshots of what I am getting. My compile, after checking the metadata box, does not include the keywords in the output.
And I don’t have the background to understand many of your suggestions. “Prefix”? “YAML”?
I have only basic familiarity with Terminal. (ie I am aware it exists and can help automate tasks.)
I love how Scrivener can export all these files (which only contain an idea or brief description) individually as .md files. The .md files can be immediately dropped into Obsidian. But the <$keywords> command does not include keywords into the compiled doc, nor does checking the metadata box. So perhaps I am doing something fundamentally wrong. I wish I could just hire someone to talk me through this via Zoom screen sharing.

I was a afraid that’s a bit much to digest…

In your compile format’s Section Layouts:

All this technical stuff aside, this raises a question:

Are there actually any keywords assigned to the documents you try to export compile? In Scrivener? Like this:


I hope you find someone (maybe even here)!

Yes, there are many keywords.
Thanks for your efforts.

1 Like

By the way, this topic has been brought up before, though I understand you not finding it when searching, if you didn’t know Obsidian uses YAML for metadata.

This describes a method where one can build custom metadata blocks for each chunk of text that needs them (in practice that could be each item in the Draft folder, or only higher level items, if say a level 2 folder contains an elaborate outline that describes the heading structure, then only the folder would want to export the metadata for Obsidian):

A post further down contains a sample project of this idea illustrated.

You might then be wondering how you could end up with 25 files out of the compiler instead of one that you have to chop up yourself. You would find an example of that in this thread. However it’s worth noting this takes advantage of Scrivener’s more advanced, programmable side of the compiler. While you wouldn’t need to be a programmer to use the setup as given (that in and of itself should be quite simple and not much more than using the compiler normally), it would require a little scripting knowledge if you wanted to make changes to how it works.

Fortunately, I do believe it would mostly work the way you want, as the person I made it for had similar desires. It doesn’t have the metadata example built into it (they intended to type in their own into the draft folder), but it would be very easy to combine example (A) with example (B) to get a single Section Layout that both signifies a file chopping point, and one that exports keywords and other useful metadata.


Thanks for your efforts but I think this all presumes a computer science degree. I’m a writer. I just want my documents to include the keyword/hashtags in the document somewhere - and I assumed you could do that during the export, not the compile process.
Luckily, I have found a work-around. 1. Put a hashtag in front of each keyword. 2. when in the document, copy and select the hashtagged keywords from the window and paste them into the text body.

To clarify for anyone else coming along, all of that is done in the user interface, using the same kinds of tool you would use to, for example, automatically number your headings. The hard work is already done behind the scenes with the setup of the project and its compile settings. I don’t have a computer science degree, either.

At any rate, glad you found something that works.

I’m glad you’ve found a solution, but what’s your objection to the Compile command? Export isn’t really designed to customize the output, but Compile is.