Imported categories are not in parent category

Hi all!

I’m trying to duplicate the structure of a category (copy all sub-categories from the previous version 26 to new version 27).

What I’m doing :

  • I create my new category 27, and note its id
  • I export a json with command discourse export_category 26
  • I edit the json file to keep only categories, I change the slugs to keep them unique, …
  • for each sub-category, I set “parent_category_id”: new category id

I then import my edited json with discourse import_category file.json

My sub-categories are then imported but NOT in my new category, they have no parent.

What is the right way to import in a category?

2 Likes

Does setting the parent in the category settings work?

Yes, the manual change is OK

1 Like

@AudeF would you be able to explain in some more detail what your site is about and what you’re trying to do? Why do you need to duplicate the strucuture of a category and all its subcategories?

Can you also show your work in some more detail here, eg how exactly did you export the json and then import it again?

Some time has passed since you asked so perhaps in the meantime you’ve figured some things out?

1 Like

Well, I’ve set the parent category manually, so it’s ok for now, but I’d like to not have to do it again next year :sweat_smile: .

We use our forum to discuss the tests of our software with external users. We have a new version each year, and we don’t want to mix new tests with older discussions, so we create a new category for each version. The sub-categories are mostly the same each time so I don’t want to create them by hand again and again :wink: .

I use this tutorial to export and import the json files: Move topics from one Discourse instance to another , except that I do it for the same forum so I change the slugs and ids to avoid conflicts.

2 Likes