This guide explains how to convert all existing topics in a Discourse category to wikis.
Required user level: Server administrator with SSH access
Discourse allows categories to have topics marked as wikis by default. This setting ensures that any new topic within the category automatically becomes a wiki.
However, if you’ve enabled this setting for a category that has already existed for some time, you may want to convert all pre-existing topics in that category to wikis as well.
Follow these steps if you wish to apply wiki status to older topics after enabling automatic wiki creation.
Convert topics to wikis
-
Make sure you backup your site just in case something goes wrong.
-
Get the id of the relevant category from the category’s URL. For example, the category id of this link to our Documentation category is
10
:https://meta.discourse.org/c/documentation/10
-
SSH into your server and run each of the following commands, replacing
<MY_CATEGORY_ID>
with the actual id:cd /var/discourse ./launcher enter app rails c tids = Topic.where(category_id: <MY_CATEGORY_ID>).pluck(:id) Post.where(topic_id: tids, post_number: 1).update_all(wiki: true)
That’s it! Your category has been wikified
Last edited by @SaraDev 2024-10-30T23:14:13Z
Check document
Perform check on document: