How do I display metadata in the current file?

I have tried searching for the answer to this (here and Google and YT), but I suspect (since I’m new) there’s something I just don’t know about.

I have a series of notes - for a book list. Each file(book) has the same metadata. I would like to display some of those metadata at the top of my note. My preference is to point to the metadata and retrieve that value. However, I am unable to to this.

I think I have everything I need, Dataview chief among them. All I know is that there is this functionality that just flatly does not work for me:

‘=this.metadata’

There is no ajaxy-behavior when I attempt to enter field info as I type. I’m rather stymied as I don’t know how to coax any of my notes into displaying metadata (outside of just globally turning the whole block on/off, which I know about, but do not want the behavior of).

Thanks in advance for any help you can offer.

What I’m trying to do

If you are using Dataview would it work for you to use the in-line metadata notation

This allows you to have metadata outside of the initial YAML block

For example


notVisibleMetadata01: “not visible in note when in reading mode”

visibleMetadata:: “I’m visible in reading mode”

So basically you can pick and chose what you want to have as visible metadata in your note when in read mode.

Not sure if this helps

So after doing some digging I think what you are after is this:

``` dataviewjs
$=dv.span(dv.current().file.frontmatter)
```

This

Plus the dataview JS docs did the trick

Hi there,

Thanks so much for responding…Multiple times… :slight_smile:

That definitely shows all my metadata, but what if I only want to show some of my metadata. And I was hoping to put individual (chosen) values into a table and use that as my template.

I am sure I’m missing something… because I’m so new. Thanks very much for taking a crack at it.

1 Like

If you copy and ‘paste and match style / paste as plain text’ (or whatever the wording is on a computer) the two lines below, you don’t get any output in live preview or reading mode?

`=this.file.name`
`=this.file.ctime`

EDIT

In your:

‘=this.metadata’

… are you actually using backticks? If not, that might be the issue.

`=this.metadata`

Thank you for pointing out the backticks. I was not using those and that was at least half my problem.

The other half still remains, which is displaying a piece of metadata (in this use-case, it’s ‘author’).

Super thanks for fixing my syntax. :slight_smile:

1 Like

Oh god. It’s just:

=this.METADATA

Sorry for being thick! Thanks!

2 Likes

Not thick at all. Lots to engage with. Enjoy.

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