# List pages that have no links to them? (orphan pages)

**URL:** https://community.silverbullet.md/t/list-pages-that-have-no-links-to-them-orphan-pages/3360
**Category:** Troubleshooting
**Created:** [October 8, 2025, 8:13pm UTC](https://community.silverbullet.md/t/list-pages-that-have-no-links-to-them-orphan-pages/3360 "2025-10-08T20:13:09Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Herald](https://community.silverbullet.md/user_avatar/community.silverbullet.md/herald/32/1818_2.png) [@Herald](https://community.silverbullet.md/u/Herald)
#### Post date: [October 8, 2025, 8:13pm UTC](https://community.silverbullet.md/t/list-pages-that-have-no-links-to-them-orphan-pages/3360/1 "2025-10-08T20:13:09Z")

</div>

I’m trying to reproduce [this query](https://community.silverbullet.md/t/list-orphan-pages-dead-links/1798/4) in SilverBullet v2, but a query inside another doesn’t seem to work. Is there a way to do this?

The query I’m trying to make (simplified):

```auto
${query[[
  from p = index.tag "page"
  where not some(query[[
    from l = index.tag "link"
    where l.toPage == p.name
  ]])
]]}

```

Result is `Failed to execute 'continue' on 'IDBCursor': The transaction has finished.`

---

<div class="post-metadata">

### Author: ![zef](https://community.silverbullet.md/user_avatar/community.silverbullet.md/zef/32/7_2.png) [@zef](https://community.silverbullet.md/u/zef)
#### Post date: [October 9, 2025, 8:11am UTC](https://community.silverbullet.md/t/list-pages-that-have-no-links-to-them-orphan-pages/3360/2 "2025-10-09T08:11:40Z")

</div>

Right, indeed nested queries are not going to work. This is what I was able to come up with:

````auto
```space-lua
function orphanPages()
  -- Collect all page names of non meta-pages and put them in a map
  local orphans = {}
  for name in query[[
    from tags.page
    where not table.find(_.tags,
      function(t) return t:startsWith("meta") end)
    select _.name
  ]] do
    orphans[name] = true
  end
  
  -- Then delete all the ones that have links to them
  for linked in query[[from tags.link select _.toPage]] do
    orphans[linked] = nil
  end
  return table.keys(orphans)
end
```

${orphanPages()}

````

Caveat here is that I found a subtle bug that I fixed in 2.1.8 which I _just_ released, so please upgrade to that before trying this.

---

<div class="post-metadata">

### Author: ![Herald](https://community.silverbullet.md/user_avatar/community.silverbullet.md/herald/32/1818_2.png) [@Herald](https://community.silverbullet.md/u/Herald)
#### Post date: [October 9, 2025, 4:19pm UTC](https://community.silverbullet.md/t/list-pages-that-have-no-links-to-them-orphan-pages/3360/3 "2025-10-09T16:19:08Z")

</div>

Thanks so much! It seems to work, at the bottom I get some weird stuff but I’ll try and figure it out.

 ![image](https://community.silverbullet.md/uploads/default/original/2X/1/106086c5b819cd3161198d8a92622d75865adbdd.png)

---

<div class="post-metadata">

### Author: ![cedric](https://community.silverbullet.md/letter_avatar_proxy/v4/letter/c/ecd19e/32.png) [@cedric](https://community.silverbullet.md/u/cedric)
#### Post date: [July 12, 2026, 10:05am UTC](https://community.silverbullet.md/t/list-pages-that-have-no-links-to-them-orphan-pages/3360/4 "2026-07-12T10:05:36Z")

</div>

Hello Zef,

Thank you. I tried this but it show all pages not only orphan pages... I don't know what is wrong

Have silverbullet 2.9.0
