Adding the file folder name at the top of the note

I am quite new to dataview and trying to make sense of it. I would like to show the name of folder on the first row of the note

Things I have tried

  1. This approach list all the files in the folder, but no folder name. Furthermore, I need the folder name for the current file only
list WHERE contains(file.folder, this.file.folder)
  1. this one shows “dataview: quey returned 0 results”. Same happens if I change “this.file” with “current.file”
list WHERE contains(file.folder, this.file)

What I’m trying to do

You can use inline dataview. Just include this line

`=this.file.folder`

Make sure you enable inline dataview query in dataview settings

It returns parsing failed error . Am I missing something?
– PARSING FAILED --------------------------------------------------

1 | =this.file.folder
| ^

Expected:

query type (‘TABLE’, ‘LIST’, ‘TASK’, or ‘CALENDAR’)

This is an inline dataview query which means you don’t need to put this into a dataview code block. Just put the command into the body of your note enclosed in single backticks. It will render the Folder that the note belongs to.

For example you can prefix it with a descriptor like below:

This file exists in the following folder: =this.file.folder (don’t forget to enclose the command in single backticks)

You can use inline dataview queries anywhere in your notes.

geez, I feel stupid.
I tried with single and double backticks but it always returns the string =this.file.folder
Checked the settings and it says “=” is the default inline query prefix.

It should work. Are you sure you are enclosing the command =this.file.folder in single backticks - like below.

This File is in Folder - `=this.file.folder’

This works for me so if your mileage varies then I am fresh out of ideas.

you might be on to sth. try enter anything above that line and delete that line. i think inline dataview won’t render the first time u create at the top of the page.

worth to also close and open obsidian just to be sure

This how your code should looks like. I include both inline and DQL block

1 Like

Inline version still not working, but the DQL version works fine. Thanks!

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