Link from Dataview Inline Query

What I’m trying to do

In my file Jane I have this Dataview inline query: = this.mother, which in Live Preview turns to “Jeannette Doe” (the value of the frontmatter data for mother).

I want this to be an internal link to the mother, like [[Jeannette Doe]], but when I put the double braces around the Dataview inline query, the live preview is an internal link to “= this.mother” (which obviously doesn’t exist).

Things I have tried

  1. Put spaces between the query and the brackets: [[ = this.mother ]]
  2. replace = this.mother with <%+ tp.frontmatter.mother %> (internal link looks right, but points to “<%+ tp.frontmatter.mother %>”

Try link()


link(path, [display])
Construct a link object from the given file path or name. If provided with two arguments, the second argument is the display name for the link.

link("Hello") => link to page named 'Hello'
link("Hello", "Goodbye") => link to page named 'Hello', displays as 'Goodbye'
1 Like

thank you so much ^^
of course it was something as simple as that xD

1 Like

Can I use link() for external links as well?

e.g. if I have the twitch username inside the frontmatter and I want to link it like this: [= this.twitch](, but to the specific twitch page?

So the outcome ist like this: [JaneLP](

I tried something like [= this.twitch]( this.twitch). and [= this.twitch]( link(this.twitch))., but that didn’t work :confused:

A few comments, first of all using the link() as @sanyaissues suggests is a perfectly valid solution, but in order to prepare for the second case I would like to also present another variant:

`= "[[" + this.mother  + "]]" `

Here we build the full link within the inline query, and that works better than doing the brackets on the outside. A similar approach could be used to build the twitch link, if you do like the following:

`= "[" + this.twitch + "](" + this.twitch + ")" `

Finally, since Obsidian now fully supports links in the frontmatter, you might want to consider changing the definition of mother into:

mother: "[[Jeanette Doe]]"

Which would allow for the simpler `this.mother` alternative in your text. This would also make that link appear in the backlinks pane, and be possible to rename, and do whatever you want to do with links…

1 Like

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