Migrate from Drupal to PagibleAI CMS

The Drupal importer moves the nodes of Drupal 7 or newer into PagibleAI, including their fields, paragraphs, layouts, media, custom blocks, redirects, access restrictions and translations.

This guide covers the Drupal-specific parts. Read Migrate to PagibleAI first for installing the importer, the options all importers share and the checklist after the import.

Connect the Drupal database

Add the Drupal database to the connections array in config/database.php:

'drupal' => [
    'driver' => 'mysql',
    'host' => env('DRUPAL_DB_HOST', '127.0.0.1'),
    'database' => env('DRUPAL_DB_DATABASE', 'drupal'),
    'username' => env('DRUPAL_DB_USERNAME', 'root'),
    'password' => env('DRUPAL_DB_PASSWORD', ''),
],

If the Drupal tables have a prefix (the prefix value of the database in settings.php), add the same value as prefix setting to the connection, e.g. 'prefix' => 'drupal_',. The Drupal importer has no --prefix option.

Run the import

If the Drupal site restricts nodes to logged-in users or roles, set up frontend access control before the import. Otherwise, restricted nodes fail to import. Then check what would be imported:

php artisan cms:drupal-import --domain=example.com --file-base=https://example.com/sites/default/files --dry-run

Then run the import without --dry-run. Always pass --file-base with the public URL of the Drupal files. Without it, the imported files keep relative URLs that browsers can't load from the PagibleAI site.

The pages are imported as English pages by default. If the default language of the Drupal site is another one, pass it with --lang, e.g. --lang=de. Otherwise, the pages get the wrong language and English translations are skipped.

By default, the content types page, article and book are imported. Use --types for other ones:

php artisan cms:drupal-import --domain=example.com --file-base=https://example.com/sites/default/files --types=page,article,event

Page hierarchy

The page tree is built from the menu, the book outlines and the URL aliases. The importer uses the main menu, or main-menu in Drupal 7; pass another one with --menu.

  • Menu links to other targets become redirect pages.
  • Menu links to Views pages become disabled placeholder pages. Add their content in PagibleAI, e.g. with a blog list or dynamic content.
  • The front page node is imported into the root page if the import created the root page. Otherwise, it's imported as normal page with a warning.
  • With --terms, the terms of the given vocabularies that have a URL alias become hidden pages listing their newest 100 nodes, e.g. --terms=tags,categories.

Content

The fields of the nodes, paragraphs, media and custom blocks become content elements. The filters of the text formats are applied, including media and entities embedded into the texts. Custom blocks of the theme regions and those referenced by fields become shared elements, which you can edit in one place.

Nodes using Layout Builder are imported with the blocks of their sections in the order of the layout regions. The layout of the node is used if it was overridden, otherwise the default layout of its content type. In Drupal 7, Panelizer displays and the custom content panes of the Panels module are imported the same way.

The meta data comes from the Metatag module, the body summary and the taxonomy terms. In Drupal 7, field collections become paragraphs.

Not imported: Comments, users, Webform forms and the listings of Views. Webforms are reported in the output. Rebuild forms and listings with PagibleAI elements or dynamic content.

Private files

Files of the Drupal private file system are linked by their /system/files/ URLs. Drupal serves them only while it runs and only to users with access to them. Before you shut down the Drupal site, move files that should stay public to the public file system, or upload them to PagibleAI and replace them on the pages. Files only for logged-in users belong on pages with frontend access.

Access, drafts and redirects

  • Access: The access values of the pages are taken from the view grants of the node access modules. The values must exist in PagibleAI. If a Drupal role has another name there, map it with --role, e.g. --role=premium_member:premium. If a restricted node fails to import, its page from an earlier import is disabled, so it doesn't stay public.
  • Drafts: Newer draft revisions and scheduled publications become pending versions, which cms:publish publishes at their date. Unpublished nodes aren't imported unless you pass --unpublished, which imports them as disabled pages.
  • Redirects: The redirects of the Redirect module become hidden redirect pages. With --node-redirects, the /node/{nid} paths also redirect to the imported pages.

Translations

Translated nodes become language variants of the imported pages. In Drupal 7, translations of the Content Translation and Entity Translation modules are supported. Use --language to import a Drupal language with another language code or on a separate domain. The value is the Drupal language code, the language code in PagibleAI and an optional URL:

php artisan cms:drupal-import --domain=example.com --file-base=https://example.com/sites/default/files --language=de:de --language=fr:fr:https://example.fr/

If Drupal detects the language by the URL path, its prefix like /de/ is added to the URLs of the translations, unless the language has its own domain. Translations in languages without a valid language code are skipped with a warning.

How language variants work in PagibleAI is described in Multilingual websites.

Domain Access

Sites using the Domain Access module are imported into one site by default. To import each domain as its own site, run the import once per domain with the Drupal domain (machine name or ID) and the PagibleAI domain:

php artisan cms:drupal-import --drupal-domain=shop --domain=shop.example.com --file-base=https://example.com/sites/default/files
php artisan cms:drupal-import --drupal-domain=blog --domain=blog.example.com --file-base=https://example.com/sites/default/files

Options

Besides the common options like --domain, --lang, --editor and --since, the Drupal importer accepts:

Option
Default
Description
--file-base
Base URL of the Drupal files, e.g. https://example.com/sites/default/files
--types
page,article,book
Content types to import
--menu
main, main-menu in Drupal 7
Menu used for the page hierarchy
--language
Drupal language imported with another code or domain, e.g. de:de or fr:fr:https://example.fr/; repeatable
--unpublished
Import unpublished nodes and translations as disabled pages
--node-redirects
Redirect the /node/{nid} paths to the imported pages
--terms
Vocabularies whose terms with URL alias become hidden pages listing their newest 100 nodes
--role
Drupal role mapped to another access value, e.g. premium_member:premium; repeatable
--drupal-domain
Machine name or ID of the Domain Access domain whose nodes are imported
--prune
Move pages, translations, shared elements and files of earlier imports that weren't updated to the trash

Run the import again

Run the same command again to update the pages while editors still work in Drupal. With --since, only the nodes changed since the date are rendered again, and the other pages stay as they are.

Unlike the other importers, the Drupal importer doesn't disable pages whose nodes were deleted or unpublished. It only reports pages, translations and shared elements that weren't updated. To move them to the trash, run a full import with --prune and the same options as before. --prune can't be combined with --since. See Migrate to PagibleAI for the details.

Troubleshooting

The import fails with a missing table error

The Drupal tables have a prefix. Add the prefix value from the settings.php of the Drupal site as prefix setting to the connection in config/database.php.

Restricted nodes fail to import

Frontend access isn't set up, or the access values of the Drupal roles don't exist in PagibleAI. Set up frontend access control, create the values or map the roles with --role, and import again.

Images and files don't load

The import ran without --file-base, so the files have relative URLs. Import again with the public URL of the Drupal files, e.g. --file-base=https://example.com/sites/default/files. The Drupal server must keep serving the files at that URL.

Files with /system/files/ URLs stopped working

They are stored in the Drupal private file system, which only Drupal serves. Upload the files to PagibleAI and replace them on the pages, or move them to the public file system before you shut down Drupal.

The pages have the wrong language

The default language of the Drupal site isn't English. Import again with --lang and the language code of the Drupal default language, e.g. --lang=de.

The front page was imported as normal page

The root page already existed before the import. Move the content of the imported front page into the root page in PagibleAI.

A Views page is empty

Views can't be imported, so their menu links become disabled placeholder pages. Add the content in PagibleAI and enable the page.

Deleted nodes are still online

The Drupal importer only reports pages that weren't updated. Run a full import with --prune to move them to the trash.