How to delete unlinked mentions

I am new with Obsidian, but like it ver much. I searched this forum, but did not find an answer to my question: How can I remove unlinked links?
Example: I wrote a text with [[example]] and made another note with the title ‘Example’. Later I decide to remove my note ‘Example’. Now I see in my other notes still [[Example]] (with hooks). Is there a possibility to remove these hooks in one (simple) way :slight_smile:

Michel Serné
The Netherlands

I understand your answer. My question has to do also with more than one note. For example 10 notes with the same link to [[example]]. Is it possible to remove in all 10 notes the same link with one simple action?

Thanks for your answers and help!

Using a plugin to locate dangling links

After you delete the file, e.g. “Example”, all the previous links to that becomes links to a non-existing files, or what someone like to call a dangling link. And there is a plugin, aptly named Dangling links, which can show all of these in a side panel.

So if you’ve deleted this file, and installed this plugin, you can show all the dangling links in the side panel, hit the third icon, and then you should see a list and should be able to locate the “Example” links, and all the places it’s referenced.

You still have to manually remove the links yourself, but at least you get the automated list.

Using Dataview to locate remaining links

Another not variant if this is a one time thingy, is to use dataview and do something like:

## Unresolved links with origin
// Build the complete list of unresolved notes,
// with where they're defined as the origin
const unresolved = {}
Object.entries( )
  .filter( ([origin, unresolvedList]) => 
           Object.keys(unresolvedList).length )
  .forEach( ([origin, unresolvedList]) => {
    Object.entries( unresolvedList )
      .forEach( ([newNote, count]) => {
        if ( !unresolved[newNote] )
          unresolved[newNote] = []

        unresolved[newNote].push( dv.fileLink(origin) )

// Combine the two and list all unresolved notes,
// with a column listing where they're defined
dv.table(["Unresolved", "Origin(s)"],
    .sort( (a, b) => (a[0].toLowerCase() < b[0].toLowerCase() ? -1 : 1) )
    .map( item => [dv.fileLink( item[0] ), item[1] ] )

This will show you all unresolved links, aka non-existing files, aka dangling links, and a link to the origin of that particular link. Still requires the manual deletion of the link.


A non-plugin way to gather the links:

  • Search [[example

This will also match links that start with “example”; if that’s a problem you can search [[example]] OR [[example|.

([[example| matches the pertinent part of links that have link text, like [[example|more readable]]).

Whether you use this or one of the other ways to gather them, here’s a relatively quick manual way to replace them:

  • Click the first result.
  • Use Replace… (in the note menu or via Ctrl/Cmd F) to replace [[example]] with example. Don’t close the Replace panel.
  • Click the next result, click Replace All, and repeat.
  • If any results remain, they are probably links that have link text ([[example|link text]]) which you’ll have to handle manually (or with other methods).

It goes pretty quickly because the Replace menu stays open and keeps its contents when you change files.

1 Like

I just love how I present an overengineered solution with javascript and/or plugins, and you come with such an elegant solution using the basic search.

There are many ways to Rome, in deed, and this forum is educational on so many levels and different areas. I need occasionally, like here, to take a step back and enjoy the simpler route.

Kudis to you, @CawlinTeffid !

1 Like

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