4 ways to delete configuration items in Drupal 8

4 ways to delete configuration items in Drupal 8

The configuration API in Drupal 8 provides a central place for storing configuration data. This is the place where modules and themes can store its data. So, for example if a module has the settings form, the submitted form values are stored in the configuration. In the image below you can see the Redirect module's settings form and the config data for the form.

Regular site visitors and basic content editors on your site don't generate or use the configuration API. That is reserved only for developers and in some cases for site builders and/or themers. And while developing a site, module or a theme, developers sometimes need to delete certain configuration items. There are several ways to do that. Since contact forms in Drupal 8 are also configuration items, I will use the personal contact form here as the example.

By the way, you can always find the config name if you visit the /admin/config/development/configuration/single/export page and find the config item that you want to delete. The name will be displayed beneath the text area. You should omit the extension .yml

So, here are the 4 ways to delete a configuration item in Drupal 8:

  1. Drush
    drush config-delete "contact.form.personal"
  2. Drupal console
    drupal config:delete active "contact.form.personal"
  3. Devel module

    Enable the Devel module, go the /devel/php page and execute this:


  1. Config Delete module

    And if you prefer a visual way to do this, you can use my Config Delete module. Install it and then go to the /admin/config/development/configuration/delete page, choose what you want to delete and press the Delete button. If you want to install the module, this is how you can do it:
    composer require drupal/config_delete
    drush en config_delete -y


The configuration API in Drupal 8 is really great and you should use it in a proper way to ensure the stability and security of your web site. You should never make configuration changes on a live site, because you can break it. The site's configuration should always be changed on a local machine, then tested on a staging server and only after making sure that everything works fine it should be deployed to a live site.

To prevent configuration modification you can checkout the Configuration Read-only module.

About author

Goran Nikolovski is a highly experienced Drupal developer with an extensive skill set that includes PHP, MySQL, HTML, CSS and Javascript. He has experience with large Drupal sites and Drupal Commerce 2.x integration, and he is author of several Drupal modules.

You may also like