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.
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?
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
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
So in both cases these topics get treated by discourse itself at the end which should take care of possible dependencies.
Thanks a lot!