Browse cities

Now this is something new to you you and your team, isn't it? You might have already moved your website from another platform to Drupal or you might have already migrated your site from an older version of Drupal to its latest one. But not from Drupal 8 to Drupal 8.

To migrate content from your Drupal 8 site to another is a totally new challenge!

You have “problems”, we have solutions!

In fact “a” solution that we're about to present to you, in detail, here below! A two-modules involving process that allows you to cautiously and (highly important) time effectively move content from your current Drupal 8 site to another Drupal 8. 

We'll keep it simple! No need for a method with lots of steps and sub-steps when, in fact, you simply want to move your site to a new domain. And especially since we're talking about the same version of Drupal, after all.

Basically what we'll be trying to show you in the following “tutorial” is how you can:

  1. use the JSON API module for “exposing” the current content on your source site 
  2. use the Migrate module with a JSON source on the target site, so that it should “assimilate” the migrated content

And now, without any further ado, here's our step-by-step guide :

Step 1: But Why JSON API?

Why particularly this module for exposing the data that you need to transfer?

And here's the argument:

Drupal 8 provides you not just with one, but with two ways to export your JSON content:

  1. you can easily access content from any entity by adding ?_format=json to its path with the drawback (for there still is a “drawback) of having to know the path beforehand and having to extract one entity at a time. It's also very true that you could as well use Views for creating a JSON endpoint, but (for there is a “but”), it might turn out to be a true “ordeal” to configure it in order to seamlessly incorporate all the needed data (ranging from images, to authors, to  related content)
  2. as with JSON API, the content transferring content is a much smoother one. You're not conditioned to know the path of every single entity. The fact that you already know the general path of an entity type and bundle will do.

Take /jsonapi/node/article for instance. This path alone is enough for you to retrieve all the data you need by simply altering the URL. 

JSON API's flexible enough to enable you to limit the fields returned to a subset, to sort and filter your articles, to insert all the related entities in the same query etc. 

In a nutshell: JSON API's the right module for the job!

Step 2: Prepare Your Source Drupal 8 Site

Still, do not expect a too complex preparation process. There are basically just a few quick and easy steps to take:

  1. first you download and enable your JSON API module (obviously!)
  2. then you create a simple module with YAML files(s) in /MODULE/config/optional. This is all the configuration that needs to be done for “activating” your JSON API module.
  3. next, go to and simply confirm JSON as an output of that URL.

That's it! Your source site is now ready for the content transfer!

Step 3: Prepare Your Target Drupal 8 Site 

Piece of advice or “warning”, however you prefer to call it: your target Drupal 8 website should be running on Drupal 8.2.3 or on a newer release of Drupal 8. 

That way, you can be sure that your articles can get easily assimilated into your target website (which already has the matching field_image field and article content type required for a successful content migration).

And here are the steps to take:

  1. enable your Migrate module (a core one in Drupal 8)
  2. next download and install the Migrate Tools and the Migrate Plus modules (needless to add that their versions shouldn't be older than the core's version). 
  3. in the end, download the Import Drupal module, from Github, and edit its YMAL files in the /config/optional directory. This way, you'll be altering the JSON source URL making it point to the domain of the source site that you will have already created. 

Step 4: Tweak The Feeds When You Migrate Content from Drupal 8 to Drupal 8

And it's the JSON API module that comes to streamline the whole feed tweaking process!

Your primary path will have this structure:


… this is the path where your source Drupal 8 site is valid.

This is where you'll see all your articles displayed, grouped in a JSON feed. The uid/author makes reference to the related users and field_image to the related images.

Now if you need to access all the related images, you can easily visualize all the details about them by simply modifying the path itself:


For including authors, too, here's how your path would have to look like:


Note: always manually test the resulting path in your browser (or maybe using Postman for that). This way, you can be sure that it's a valid JSON that you ended up with at that path.

Step 5:  Migrate Content from Your JSON Source

And here is where the Migrate Plus module comes in!

Now let's focus on the source configuration. We'll try pointing out, here below, some of its critical components:

1. The file-based imports (XML, JSON) have the same pattern, the single variation being in the parser: for JSON and XML this (the parser) is in the Migrate Plus module:

  plugin: url  data_fetcher_plugin: http
  data_parser_plugin: json


2. It's in the URL that JSON is being served:

urls: /> 3. You'll need to track the unique id in the feed. For instance, when pulling nodes from Drupal, it's the “nid”:

      type: integer


4. Also, you'll need to indicate Migrate where precisely, in the feed, to search for the content that you need to read. Postman can come in handy here, once again, as it will show you how your data is configured.

For instance, when the source uses the JSON API module, you'll get the following array: item_selector: data/

5. Last, but definitely not least: you'll need to indicate your Migrate module the fields, as well. And, speaking of fields, you should know that in the JSON API they are all cluttered up together under the key item selector.

      name: nid
      label: 'Nid'
      selector: /attributes/nid


Step 6: Get Everything Ready for the Image Migration Process

Now, let's try migrating nodes along with their images!

First, set the author (choosing an existing one). 

Then it's two separate migrations that you'll need to create:

  • one will pick up the related images
  • the other one will handle the nodes

And now you should know that there are two ways of processing images starting with the Drupal 8.2.3 release:

  • one processes local images
  • the other one processes the remote images

Note: one of the main advantages when you migrate content from a Drupal 8 site to another is that you inevitably get the Drupal 8 source value in the right D8 format: />  

Step 7: Run the Migration Process 

Now everything's set up, so you can go ahead and type in THE command launching your migration process:

drush migrate-status

In fact, it won't be “a” migration, but two migrations, which the YAML files will run in the right order. Run them by inserting this command:

drush mi --all 

And here are your two migrations:

  1. import_drupal_images, which uses the path including the related image details 
  2. import_drupal_articles, which extracts the article information (except the included images), matching each article with the images pulled during the aforementioned migration.

You get to run one migration at a time and even to rollback and start over:

drush migrate-rollback import_drupal_images

By now, if all went smoothly and incidents-free, you should be looking at the content (images here included) that the Migrate module will have pulled in!

If, in addition to content, you'll want to migrate your taxonomy and users, you'll need to set up and run separate migrations for each one of them, prior to the node migration.

As you can surely tell: this is a much smoother type of migration process, since the data on your source site's already in the right format.


Your turn now! Try to migrate content from your Drupal 8 site to another following this sequence of steps!


We do Drupal development

Go to our Drupal page!

Visit page!

Recommended Stories

How Creating a Mind Map Helps You Make Your Website More User-Friendly
The line between useful and... useless (or pushy or simply annoying) is thinner than you think. That's why… (Read more)
Adriana Cacoveanu / Dec 14 '2019
Why Would You Build Your Own Cloud Native Drupal Platform? The Main Benefits and Challenges to Consider
Why or rather "when" should you consider building your own cloud native Drupal platform?  Is a container-based… (Read more)
Silviu Serdaru / Dec 12 '2019
The Web Experience Toolkit Drupal 8 Distribution: Why Use a Drupal Distribution and Why Precisely... Drupal WxT?
Say you need to build a company website that's bilingual from the ground up, accessible, responsive, user-friendly… (Read more)
Adriana Cacoveanu / Dec 10 '2019