drupal2 Min Read

Drupal 8: How to Export and Import View

Gorav Singal

May 14, 2018

TL;DR

Use Drupal 8 configuration synchronization to export views as YAML and import them into another environment, avoiding manual recreation.

Drupal 8: How to Export and Import View

Introduction

It's always a good practice to have a development environment and production environment for any kind of development. This post is for Drupal 8 development.

You have created some views, and want to port it to your production environment or want to share this with someone.

The Manual way

You can always create view manually, and change the configuration one by one manually. And, all done. But, still, there is a chance of manual error.

Doing it Drupal way

Drupal allows you to export and import a view.

To export a view in Drupal 8, follow steps:

  • Goto /admin/config/development/configuration
    You will See Synchronize title and 3 tabs:
    Synchronize | Import | Export
  • Click on Export. You will See two items:
    Full Archive | Single Item
  • Click on Single Item
    You will be asked for Configuration Type from the drop-down.
    Select View
  • Second drop down:"Configuration name", will be populated with all the views.
  • Select the desired view.
  • As you select, the next text area: "Here is your configuration" will be populated with a yml
  • You need to copy this yml

Now goto site, where you want to import that view. Follow steps:

  • Goto: /admin/config/development/configuration/single/import
  • Configuration type as View
  • Paste the yml in the textarea showing next.
  • Click on Import

If you see no error, your view has been successfully imported.

Common Error

In your view, you might have referred some fields from some content type. You need to ensure that the field names are same in both environments. Else, you need to modify the yml copied.

For example, You might have created a new image style named: 300x200 in the development environment. And, you have not created this image style in a production environment.

Your yml have this reference, and when you import. It will throw an error saying that this image style is not found. You will need to create that image style, and then try again Or renaming that image style in yml, and then import.

Share

Related Posts

Drupal Code: Fetch Link, Title, Category names, tag names from every article

Drupal Code: Fetch Link, Title, Category names, tag names from every article

See the code below: The output will be 4 columns separated by comma. You can…

Drupal: How to block a user by email programatically

Drupal: How to block a user by email programatically

Many times, while administering your drupal website, you must have encountered…

Drupal 7: How to save a node programmatically and add an image field from a public URL

Drupal 7: How to save a node programmatically and add an image field from a public URL

Note: I have public URLs of these images, which I want to save. return…

Drupal 7: How to implement cron tasks (hook_cron and hook_cron_queue_info) that takes much time

Drupal 7: How to implement cron tasks (hook_cron and hook_cron_queue_info) that takes much time

hook_cron() suggests to put tasks that executes in shorter time or non-resource…

Drupal Helpful codes for database queries

Drupal Helpful codes for database queries

Being a drupal user from last around 5 years, I used to know small codes for…

How to add alt attribute of images in all of my drupal articles or other content type

How to add alt attribute of images in all of my drupal articles or other content type

I have a custom content type, and there are around 2000 number of nodes in my…

Latest Posts

AI Video Generation in 2025 — Models, Costs, and How to Build a Cost-Effective Pipeline

AI Video Generation in 2025 — Models, Costs, and How to Build a Cost-Effective Pipeline

AI video generation went from “cool demo” to “usable in production” in 2024-202…

AI Models in 2025 — Cost, Capabilities, and Which One to Use

AI Models in 2025 — Cost, Capabilities, and Which One to Use

Choosing the right AI model is one of the most impactful decisions you’ll make…

AI Image Generation in 2025 — Models, Costs, and How to Optimize Spend

AI Image Generation in 2025 — Models, Costs, and How to Optimize Spend

Generating one image with AI costs between $0.002 and $0.12. That might sound…

AI Coding Assistants in 2025 — Every Tool Compared, and Which One to Actually Use

AI Coding Assistants in 2025 — Every Tool Compared, and Which One to Actually Use

Two years ago, AI coding meant one thing: GitHub Copilot autocompleting your…

AI Agents Demystified — It's Just Automation With a Better Brain

AI Agents Demystified — It's Just Automation With a Better Brain

Let’s cut through the noise. If you read Twitter or LinkedIn, you’d think “AI…

Supply Chain Security — Protecting Your Software Pipeline

Supply Chain Security — Protecting Your Software Pipeline

In 2024, a single malicious contributor nearly compromised every Linux system on…