Blot

Metadata in a markdown file

If I have something in my YAML front matter, can I display that in my post? This does not seem to work when placed in the markdown file.


Date: September 15th, 2022
blah: Apple


{{metadata.blah}}

Asked 4 years ago Edit
5 replies

Figured it out {{entry.metadata.blah}}

4 years ago Edit

Excellent, yes, {{metadata}} is a part of the {{entry}}. All these lines produce the same result:

- {{entry.metadata.blah}}
- {{#entry}} {{metadata.blah}} {{/entry}}
- {{#entry.metadata}} {{blah}} {{/entry.metadata}}
4 years ago Edit

This is great. Is there any way to tie a CSS selector to this data in order to style it? I'm thinking about using the summary metadata after the title at the top of the post and want it to stand out. Thanks!

4 years ago Edit

You could just wrap it in a span

<style>#styleMe {color:red;}</style> 
<span id="styleMe">{{entry.metadata.blah}}</span>

or do it all in one line

<span style="color:blue;">{{entry.metadata.blah}}</span>    
4 years ago Edit

Thank you! I wrapped it in a div instead to get a nice bottom border, but used the same pattern.

4 years ago Edit

Your reply