# Convert all existing topics in category to wikis

**URL:** https://meta.discourse.org/t/convert-all-existing-topics-in-category-to-wikis/54493
**Category:** Self-Hosting
**Tags:** how-to
**Created:** [19 december 2016 om 13:34 UTC](https://meta.discourse.org/t/convert-all-existing-topics-in-category-to-wikis/54493 "2016-12-19T13:34:44Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Discourse](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/discourse/32/148734_2.png) [@Discourse](https://meta.discourse.org/u/Discourse)
#### Post date: [19 december 2016 om 13:34 UTC](https://meta.discourse.org/t/convert-all-existing-topics-in-category-to-wikis/54493/1 "2016-12-19T13:34:44Z")

</div>

> 🔖 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.

 ![Screen Shot 2022-12-01 at 5.30.18 PM](https://global.discourse-cdn.com/meta/original/4X/2/6/9/269c5cde8710c8cf867ad391355770a6b8d214f6.jpeg)

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

1. Make sure you [backup your site](https://meta.discourse.org/t/create-download-and-restore-a-backup-of-your-discourse-database/122710) just in case something goes wrong.

2. 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`

3. SSH into your server and run each of the following commands, replacing `<MY_CATEGORY_ID>` with the actual id:

That’s it! Your category has been wikified 🎉

> Last edited by @SaraDev 2024-10-30T23:14:13Z
> 
> > **Check document**
> >
> > Perform check on document:

---

<div class="post-metadata">

### Author: ![satonotdead](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/satonotdead/32/447830_2.png) [@satonotdead](https://meta.discourse.org/u/satonotdead)
#### Post date: [22 juni 2023 om 06:47 UTC](https://meta.discourse.org/t/convert-all-existing-topics-in-category-to-wikis/54493/2 "2023-06-22T06:47:10Z")

</div>

It can be used in #Wiki (tag)?

---

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [22 juni 2023 om 07:17 UTC](https://meta.discourse.org/t/convert-all-existing-topics-in-category-to-wikis/54493/3 "2023-06-22T07:17:48Z")

</div>

Hi matenauta 🙂

Yes, it would be possible by using the logic here:

[https://meta.discourse.org/t/administrative-bulk-operations/118349#move-all-topics-with-a-specific-tag-to-a-single-category-15](https://meta.discourse.org/t/administrative-bulk-operations/118349#move-all-topics-with-a-specific-tag-to-a-single-category-15)

Example (tested and working):

```rb
tag = Tag.find_by_name("design")
topics_id = Topic.joins(:topic_tags).where("topic_tags.tag_id = ?", tag.id).pluck(:id)
Post.where(topic_id: topics_id, post_number: 1).update_all(wiki: true)

```
