Configuration

Configuration is a Drupal site's setup, apart from its content: content types, fields, views and enabled modules. It can be exported as YAML files.

Learn DrupalDrupal glossary

Configuration in Drupal is the information about how your site is set up, as opposed to what it publishes. It covers the site name, enabled modules, content types, fields, taxonomy vocabularies and views. Drupal keeps it in the database by default, and you can export it as YAML files and import it on another copy of the site.

How configuration works in Drupal 11

Drupal separates configuration from other kinds of information. Content is what visitors see and editors change. Configuration is the more permanent setup of the site. State is data that changes often or automatically, such as when cron last ran. Session data belongs to one visitor's interactions.

The live copy is called the active configuration, and by default it sits in the config table of the database. Two kinds exist. Simple configuration is a named set of values, such as system.performance, where the name starts with the module that supplies it. Configuration entities, such as a content type, store each item as its own row in that table.

Developers read simple configuration with \Drupal::config('system.performance'), which returns a read-only object. To change a value they call getEditable(), then set() and save(). Setting a value without saving it does nothing.

Exported configuration lives in the sync directory. By default Drupal places it inside the site's files directory, and you can move it after installation. For an import to work, the exported files must carry the same site UUID as the target site, so you copy configuration between copies of one site, not between unrelated installs.

Moving configuration between two copies of one siteConfiguration changed on a development copy is exported with drush config:export from the database into YAML files in the sync directory, the files travel to the live site with the deployment, and drush config:import writes them into the live database.Development copyLive siteActive configurationStored in the database (config table)You change it in the admin screensSync directoryOne YAML file per itemWritten by the exportSync directoryThe same YAML files, arrived withyour deploymentActive configurationUpdated by the importThe changes are now livedrush config:exportdeploydrush config:importBoth copies must carry the same site UUID for an import to work.
How configuration moves from a development copy to the live site: export to YAML files, deploy, import.

Example

You add a field to a content type on your local copy. On your live site you want the same field. Use Drush and follow the practice described under configuration management:

drush config:export   # local: write the sync directory
        # copy the sync directory to the live site
        drush config:import   # live: review the list, answer y

Use drush config:status to see the differences between the database and the files, and drush config:get system.site to print one configuration object.

Common mistakes

  • Editing configuration on the live site. The Drupal documentation recommends against making configuration changes on a live site. Make the change on a development copy and export it.
  • Exporting over unsaved work. The Drupal.org guide to the Drush workflow warns that config:export deletes the current contents of the sync directory. Check what is in it first.
  • Editing a module's config/install files. Drupal reads that directory only when the module is installed, so changing the files later does not change the active configuration.
  • Forgetting overrides. A $config value in settings.php takes precedence over the stored value, but the admin screens do not show it. A setting that "will not change" is often overridden there.
  • Importing from the wrong site. A mismatched site UUID stops the import. Move configuration only between copies of the same site.

For marketing and content teams

Whenever you change a setting rather than a page, you change configuration: a new content type, a vocabulary, a view that lists your articles. Those changes do not travel with your content. Ask your developers how they move configuration to the live site, and avoid making the same change by hand on two environments, because the two copies then drift apart. Day-to-day publishing does not touch configuration at all.

Sources

Questions about Configuration

Content is what visitors read and editors manage, such as articles, pages, images and files. Configuration is the site's own setup: its name, content types, vocabularies and views. Configuration changes rarely; content changes every day.

By default in the database, in the config table. This is called the active configuration. You can export it to YAML files in a sync directory, which is how teams move settings between environments.

Run drush config:export (alias cex) on the source site, copy the sync directory to the target site, then run drush config:import (alias cim) there. Drush lists the pending changes and asks you to confirm.

Values set through $config in settings.php are a temporary layer on top of the stored values. The admin screens show the stored value, not the override. To see overridden values with Drush, add --include-overridden to config:get.

Related terms

All Drupal terms from A to Z