Drupalwoo ☉

Exporting and Importing Drupal Configuration with the Features Module

A Drupal build rarely stays as simple as the demo site. Once a project has a dozen content types, custom views, editorial roles, path aliases and a handful of block placements, the site has configuration worth protecting. Copying those settings by hand between environments works for a while, then someone forgets a role permission or a view filter and staging stops matching production. The Features module turns that configuration into a custom module you can commit to Git, review in a pull request and deploy like any other code.

This walkthrough covers exporting Drupal configuration into a feature module, importing it on another environment, and the decisions that sit around both operations. It is written for developers and site editors who want repeatable deployments for Australian clients, whether that means a government tender in Canberra or a marketing site for a regional business. It also sets out where the Features module overlaps with core configuration sync, because the two approaches answer similar questions in different ways.

What the Features module actually does

At its core, Features captures configuration entities and packages them into a Drupal module. When you export a feature, you get a directory containing an info file and a config folder filled with YAML for the content types, fields, taxonomy vocabularies, views, blocks, roles, permissions, path aliases or image styles you selected. Drupal loads configuration from enabled modules, so a site that enables that module ends up with the same settings.

Dependencies are recorded in the generated info file. Export a view that relies on Pathauto or Token and Features writes those modules into the dependency list, which means a deployment to a fresh environment fails with a clear message instead of an empty page or a broken filter. Content is deliberately excluded: nodes, taxonomy terms, user accounts and files stay in the database, and you move those with JSON:API, a migration or the core migrate module.

That distinction matters because configuration and content fail differently. A missing image style or view filter breaks the rendering of a page; a missing node is usually a data problem for the client to resolve. Keeping the two apart also keeps the exported module small, which makes review and merging quicker on a team juggling several builds.

Why configuration export matters for Australian Drupal teams

Australian agencies tend to run several environments at once, often for clients in different states, and the cost of drift shows up in billable hours. A custom content type agreed during a tender in Canberra is rarely the only one: marketing teams in Sydney and Melbourne ask for extra fields, then editors in Darwin or Hobart notice a mismatch on a slower NBN connection and file a support ticket. Deployed configuration closes that gap without anyone clicking through the views interface at midnight.

Billing structure adds another wrinkle. A custom module is development, and development in Australia carries GST, so a feature module that saves a day of manual configuration is easier to justify in an invoice than a plugin someone installs by hand. It also gives the agency a record of what was built: the module directory shows which views and content types belong to the project, which helps when a team hands a site over to an in-house editor three years later.

Scheduling matters too. Sites set to Australia/Sydney change clocks twice a year, while Australia/Brisbane and Australia/Perth do not, so a feature that arrives on a Friday afternoon can hit a nightly cron job in one state and miss it in another. Exporting configuration as code, then importing it in a controlled window, beats making changes live on production.

Comparing the main export and import workflows

Before choosing a workflow, it helps to see the options side by side. All of them end with configuration sitting in version control; they differ in where the files live and who triggers the change.

Approach Where the configuration lives Typical command Suits
Features module export Custom module directory in the codebase drush features:export Packaging related settings for review and reuse
Features browser interface Custom module directory in the codebase Structure, then Development, then Features Site editors working without a terminal
Core configuration sync config/sync directory outside modules drush config:export and drush config:import Full-site snapshots across environments
Hand-written module Custom module directory in the codebase Git commit and deploy Small, stable configuration changes

Features earns its keep when a project has a chunk of configuration that needs an owner, a version and a review. Core configuration sync is blunt but thorough: it exports everything in the site, which is what you want for cloning an entire environment and what you do not want when you only want to move a single content type. Running both is common and reasonable, provided you avoid storing the same entity in both places.

A useful rule is that Features holds the configuration you want to talk about in a ticket, while core sync holds the moving parts: site name, email addresses, analytics identifiers and anything else that changes per environment. Divide the two lists at the start of a project and the import steps later get much easier.

Exporting Drupal configuration as a feature

Start on the environment where the changes belong. Install the Features module with Composer alongside any contributed modules the feature depends on, and make sure your custom module directory is tracked in Git. A feature exported from production is a feature that overwrites whatever the development site already contains, so exports belong on development or staging.

From the browser, open Structure, then Development, then Features and create a new feature. Name it after what it does rather than after the project, because you will live with that name in every commit. Features offers two useful choices: generating a standalone module, which creates its own directory, and generating a feature inside an existing module, which adds to a module you already maintain. Generate a module for a large package such as a newsroom with content types, views and blocks together. Select the configuration items, tick single-use component if the items are owned exclusively by this feature, then export.

The Drush equivalent is quicker once the module exists: run drush features:export with the module name and review what appears in your working tree. Drush also lists available features with features:list, which is a handy way to audit what a site has already packaged. Either way, the export writes YAML into the module's config folder, and the first step after that is to read the diff. Look for environment-specific values that slipped in, such as a path alias pointing at a staging domain or a mail address belonging to an old staff member, because those travel with the feature unless you remove them.

Importing a feature into a target environment

Deployment starts by getting the module onto the target. Either pull the branch that contains it and copy the directory into modules/custom or modules/features, or add it to composer.json as a path repository so Composer installs it. If your project uses a pipeline, this is where the deploy tool checks out the branch, installs dependencies and runs Drush against the container or server, often hosted in an Australian region such as ap-southeast-2 to keep client data onshore.

Enable the contributed modules listed in the feature's info file first, then enable the feature itself with drush pm:enable. Drupal imports the module's configuration as it installs it, so the new content types, views and blocks appear without a separate import step. Finish with drush cache:rebuild so routes, menus and blocks pick up the new configuration, and check the log for a partial import.

If the target site already held conflicting configuration, Drupal may skip those entities or refuse the install, and that is where core's drush config:import comes in: export the target's current configuration, import the feature's YAML, and review the result in the diff view before accepting. Watch permissions in particular. A feature that grants a marketing role access to an editorial view will apply that grant on production without a second look, so treat permission changes as a deliberate approval rather than a side effect of a deploy.

Common pitfalls and how to avoid them

The most common mistake is exporting from the wrong environment. Running drush features:export on production rewrites the module files and quietly replaces local development changes with whatever production happens to hold. The second most common is a dependency gap: the feature references a module that is not installed on the target, so the view loads but renders nothing. Checking the generated info file and keeping a list of required contributed modules in your deployment notes prevents both.

Other traps include exporting an entity twice, once through a feature and once through core configuration sync, which leads to conflicting versions of the same content type; reusing a feature name after deleting a module, which leaves orphaned YAML in the repository; and assuming single-use component removes configuration from elsewhere automatically. It does not. It records that the feature owns those items so a later export does not duplicate them.

It also helps to have a second set of eyes when a feature gets large. The Gambellara Drupal guidance is a reasonable place to look for patterns on packaging configuration and keeping exports clean, and internal review by another developer on the project catches the same class of issue. For accessibility, remember that the Australian Government Digital Service Standard asks sites in the public sector to meet WCAG 2.1 AA, so changes to views, themes and media styles are configuration worth reviewing properly rather than exporting in a hurry.

Living with Features after launch

Features is a working tool rather than a one-off export. When an editor asks for a new view, a revised content type field or a different block placement, decide where it belongs: in the feature module if it belongs to the project and needs to travel between environments, or in site-specific configuration if it is a one-off for this particular install. Write that decision down next to the module so the next developer does not have to reverse-engineer it.

Minor inconsistencies are worth handling early. Drupal core uses American spellings in many places, so exported YAML can contain customize while the team writes customise in documentation and tickets. Nobody breaks a site over it, but a code review comment on every pull request is a waste of an afternoon. A short style note in the repository, or a linting rule for the exported YAML, settles it once.

Keep the ecosystem around you close as well. The Drupal Australia community runs meetups in Sydney and Melbourne and keeps Gov Drupal events going in Canberra, which are useful places to trade notes on configuration workflows with people solving the same problems. Hosting in an Australian region, documenting which feature modules a site owns, and tagging releases whenever a feature changes give a support team something concrete to work with when an editor in Perth asks why a view is missing a filter. A packaged configuration is only useful if the people maintaining it can find it.