Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to import / export content type in drupal 8?

Tags:

drupal-8

How to import / export content type with their related contents from one website to another website in drupal 8?

like image 615
user3178593 Avatar asked Jun 28 '17 12:06

user3178593


People also ask

How do I export content in Drupal 8?

In order to export content in bulk, select the desired content nodes you wish to export in the content overview. You can then select the "Export content" action from the bulk actions dropdown menu and click on the "Apply to selected items" button.

How do I copy content type in Drupal?

Access the content type list, click on "clone" for the content type you want to clone, save the clone form. The module will then clone the content type, and copy all fields to the newly created clone.


1 Answers

You'll find the drupal/console command config:export:content:type will help here.

Create a module and then run this command and it will do all the hard work for you:

drupal config:export:content:type --module=new_module --remove-uuid --remove-config-hash content_type_to_export

This will put it in the config/install directory for the module. When you enable the module on your new site, it will run this automatically.

One gotcha I had was that it adds a couple of files for config already included in core. I just deleted them and it was all fine. Basically if a yml file doesn't reference your content type in its file name, then you might not need it.

For more information:

drupal help config:export:content:type
like image 145
Cameron Avatar answered Nov 26 '22 08:11

Cameron