Drupal - How do I export/import views?

Views are available through configuration in Drupal 8, and can be exported via the Configuration Management interface.

In the admin menu select "Configuration" in the DEVELOPMENT section, select "Configuration synchronization": Drupal 8 Configuration Development menu area

In that menu area, the Export tab leads to the path: http://sitename/admin/config/development/configuration/single/export

In that area, a single view can be exported or imported, and the steps are about the same so I'll include Export here to help explain.

  1. Select 'Export' menu tab.
  2. Select 'Single item' sub menu tab.
  3. From the first item drop down 'Configuration type' select 'View'.
  4. From the second item drop down 'Configuration name' select the name of your view.

The result is a views.view.view_machine_name.yml "YAML" file that can be copy pasted into the 'Import' area.


Views are configuration entities in Drupal 8, and can be exported via the Configuration Management module.


If you'd like to export a view for use in the default configuration of a custom module, you can run a Drupal Console command:

drupal config:export:view

See: config:export:view docs page.

Tags:

Views

8