# Bulk delete of old and spread topics

**URL:** https://meta.discourse.org/t/bulk-delete-of-old-and-spread-topics/157707
**Category:** Support
**Created:** [14 ביולי,‏ 2020,‏ 2:06pm UTC](https://meta.discourse.org/t/bulk-delete-of-old-and-spread-topics/157707 "2020-07-14T14:06:10Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![klopsknoedel](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/klopsknoedel/32/194126_2.png) [@klopsknoedel](https://meta.discourse.org/u/klopsknoedel)
#### Post date: [14 ביולי,‏ 2020,‏ 2:06pm UTC](https://meta.discourse.org/t/bulk-delete-of-old-and-spread-topics/157707/1 "2020-07-14T14:06:10Z")

</div>

Hi,

we have thousands of old/obsolete topics across our forum which we like to delete. I already searched meta for an appropriate way to achieve this but couldn’t found a proper solution.  
Would it be enough to iterate through a list of topic-ids and set the `deleted_at` - flag of each topic we like to “delete” or is there a better way? I know it’s a quite lazy solution.  
I think it is a little bit of overhead to write an extra (small) plugin to make use of `Topic.destroy` for a bulk-delete.

Kind Regards  
Sascha

P.S.  
Context: These topics produces crawling-issues and soft404 and we like to hide them from search engines. Deleted topics are excluded from our sitemap.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [14 ביולי,‏ 2020,‏ 3:07pm UTC](https://meta.discourse.org/t/bulk-delete-of-old-and-spread-topics/157707/2 "2020-07-14T15:07:16Z")

</div>

Perhaps you just want to unlist them? That should keep them from being indexed.

Do you want to do this once, or on a regular basis?

---

<div class="post-metadata">

### Author: ![klopsknoedel](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/klopsknoedel/32/194126_2.png) [@klopsknoedel](https://meta.discourse.org/u/klopsknoedel)
#### Post date: [14 ביולי,‏ 2020,‏ 7:39pm UTC](https://meta.discourse.org/t/bulk-delete-of-old-and-spread-topics/157707/3 "2020-07-14T19:39:53Z")

</div>

Hi,

yes, we want to unlist them and keep them from being indexed.  
This will be done once as we can adjust any upcoming “faulty” topic/post, which produces crawling issues, by hand.

Our forum is very old (started 1996) and got migrated a lot of times with weird/old syntax in raw-text and other stuff. We’ve collected all topics which are older than 2015, with less than 1000 views and pop up in Google’s search console as “faulty”.

For us it’s ok if these topics are just flagged as deleted but wasn’t quite sure if setting `deleted_at` directly is a good idea or if there are any dependencies we should care about. So if we should go the programmatic way.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [14 ביולי,‏ 2020,‏ 9:11pm UTC](https://meta.discourse.org/t/bulk-delete-of-old-and-spread-topics/157707/4 "2020-07-14T21:11:30Z")

</div>

If you want to delete them, then I think that you really want to call `topic.delete`. If there are any dependencies, then that’ll handle them.

---

<div class="post-metadata">

### Author: ![klopsknoedel](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/klopsknoedel/32/194126_2.png) [@klopsknoedel](https://meta.discourse.org/u/klopsknoedel)
#### Post date: [15 ביולי,‏ 2020,‏ 10:14am UTC](https://meta.discourse.org/t/bulk-delete-of-old-and-spread-topics/157707/5 "2020-07-15T10:14:23Z")

</div>

Thanks for your advice! In case we choose to delete those topics completely I’ll set `deleted_at` and `visible=false` via a SQL-Query. Those topics will be deleted by a sidekiq-job after 30 days.  
But if these topics should be kept, I do what you suggested and “delete” them via a little ruby-snippet using `topic.delete`.  
So in both cases these topics get treated by discourse itself at the end which should take care of possible dependencies.

Thanks a lot!
