List backlinks without corresponding forward link

What I’m trying to do

Is there any way to list only those backlinks (that is notes that link to the current note) for which there dos not exist a forward link (link from the current note to the other note).

For MOC notes, I find that if a given note links to it (in a links-as-tags way), it should generally be integrated into the MOC note. I might link to a relevant MOC as I write a note, and then go through the MOC note later, checking backlinks and integrating them. But for larger MOCs, it becomes hard to match them up, so I would like to list only those backlinks that have not already been integrated as forward links.

Things I have tried

I found the obsidiantools python package which would probably work, but I’d like to have this available inside the note itself.

Thanks for Obsidian and for your help!

Basically what you’re asking for are links within this.file.inlinks which aren’t already present in this.file.outlinks.

Try out the following, where the last query should give you what you want when it is run from inside your MOC. It should also be easily extendable into a query which could be run from each and every MOC you’ve got.

Test setup:
- [[In Moc 1]] & Outside 1 points to this file
- Outside 2 doesn't point anywhere
- [[In Moc 3]] exists, but no links
- [[In Moc 2]] and [[In Moc 4]] doesn't even exists

## Current in- and outlinks

```dataview
TABLE this.file.inlinks, this.file.outlinks
WHERE file = this.file
```

## Inlinks not mentioned in outlinks

```dataview
LIST WITHOUT ID inlink
FLATTEN this.file.inlinks as inlink
WHERE file = this.file
  AND !contains(this.file.outlinks, inlink)
```

Update: This might be the global variant where you replace the FROM #f67427 with some expression limiting the file set to your MOC’s. Maybe something like FROM #MOC?

```dataview
LIST rows.inlink
FROM #f67427 
FLATTEN file.inlinks as inlink
WHERE !contains(file.outlinks, inlink)
GROUP BY file.link
```
1 Like

Thanks, this is a great solution. I’ve put your suggestion into a template (my only change was to add sorting), and I insert that template into pretty much all MOC and central pages, generally under the heading “Other Backlinks”.

LIST WITHOUT ID inlink 
FLATTEN this.file.inlinks as inlink 
WHERE file = this.file 
  AND !contains(this.file.outlinks, inlink)
SORT inlink.name ASC

This makes my note taking experience so much better!

1 Like

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