Bulk delete of old and spread topics

AI-generated summary

The discussion revolves around bulk deleting old and obsolete topics in a forum that started in 1996. klopsknoedel wants to delete thousands of topics that produce crawling issues and soft 404s, and is looking for the best approach. pfaffman suggests unlisting them to prevent indexing.

klopsknoedel clarifies that they want to unlist the topics and keep them from being indexed, and this will be a one-time process. They have collected topics older than 2015, with less than 1000 views, and those that appear in Google’s search console as “faulty”.

pfaffman advises that if deletion is desired, calling topic.delete is the best approach as it handles dependencies. klopsknoedel thanks pfaffman for the advice and plans to either use topic.delete or set deleted_at and visible=false via SQL, allowing Discourse to handle dependencies in both cases.

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.

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?

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.

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.

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!