How to import / export content type with their related contents from one website to another website 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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With