Migrate from Statamic to PagibleAI CMS

The Statamic importer moves the entries of Statamic collections into PagibleAI, including their Bard and Replicator content, assets, SEO data, redirects and localized sites.

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

Move the content into a database

The importer reads the database of the Statamic Eloquent driver, which requires Statamic 3.3 or newer. If your Statamic site stores its content in flat files, install the driver and move the entries, the collections with their routes, trees and settings, and the blueprints with the field settings into the database. Move the assets as well, so the importer gets their titles and alternative texts. For localized sites, move the sites too, so the importer knows their languages and URLs. This changes how the Statamic site stores its content, so run it on a copy of the site, not on the live one:

php please eloquent:import-entries
php please eloquent:import-collections
php please eloquent:import-blueprints
php please eloquent:import-assets
php please eloquent:import-sites

Not all of this works in older Statamic versions:

  • Asset titles and alternative texts are read from Statamic 4.21 on. In older versions, the assets are imported without them.
  • eloquent:import-sites requires Statamic 5.16 or newer. In older versions, pass the language code and URL of each site with --language, as described in the section about localized sites below.

Connect the Statamic database

Add the Statamic database to the connections array in config/database.php. The prefix must match the STATAMIC_ELOQUENT_PREFIX of the Statamic site:

'statamic' => [
    'driver' => 'mysql',
    'host' => env('STATAMIC_DB_HOST', '127.0.0.1'),
    'database' => env('STATAMIC_DB_DATABASE', 'statamic'),
    'username' => env('STATAMIC_DB_USERNAME', 'root'),
    'password' => env('STATAMIC_DB_PASSWORD', ''),
    'prefix' => env('STATAMIC_ELOQUENT_PREFIX', ''),
],

Run the import

Pass the collections to import and the base URL of the assets. Check what would be imported first:

php artisan cms:statamic-import --domain=example.com --collections=pages,blog --file-base=https://example.com/assets --dry-run

Then run the import without --dry-run. Import all collections in one run if possible, because links to entries are only resolved within the collections of the same run. Links to entries of other collections are lost in separate runs. If you still need separate runs, use a different --editor value for each, because pages of earlier imports whose entries aren't part of the current run are disabled:

php artisan cms:statamic-import --domain=example.com --collections=pages --editor=statamic-pages --file-base=https://example.com/assets
php artisan cms:statamic-import --domain=example.com --collections=blog --editor=statamic-blog --file-base=https://example.com/assets

Entries and fields

Entries become pages with their Statamic URLs. Structured collections keep the order and hierarchy of their trees, and mounted collections are imported below their entry.

The content is read from the entry fields body, content, article, text, page_builder, page_sections and blocks. If your blueprints use other field names, pass them with --fields, e.g. --fields=main,sections. These field types are converted using the field settings of the blueprints:

  • Bard, Replicator, Group, List and Array
  • Markdown, Text, Textarea and HTML
  • Table, Code, Link, Video and Asset

Links to entries point to their pages. SEO Pro data and meta_*/og_* fields become the meta data.

Not imported: Navigations, taxonomies, globals, forms, revisions, Grid fields and Antlers templates.

Assets

Assets are referenced by their URL and not downloaded. Without --file-base, the asset URLs are unknown and the assets aren't imported. Their titles and alternative texts are taken from the asset data moved with eloquent:import-assets.

If the asset containers use different URLs, pass one --file-base per container. Asset values without container belong to the only container, or to assets; set another one with --container:

php artisan cms:statamic-import --domain=example.com --file-base=assets=https://example.com/assets --file-base=images=https://cdn.example.com/images

Status and redirects

  • Draft entries aren't imported.
  • Private and protected entries become disabled pages. Enable them or set their frontend access after the import.
  • Scheduled entries are published by cms:publish at their date, which the Laravel scheduler runs every 30 minutes.
  • Entries with a redirect field become redirect pages.

Localized sites

The first site, or the one named default, is imported as source language. Use --site for another one. Localized entries of the sites passed with --language become translations. The value is the site handle, the language code and the URL path or domain of the site.

If the sites were moved into the database (Statamic 5.16+), the site handle alone is enough, e.g. --language=de. The language code and the domain of the site are then taken from the database. Pass the full value in older versions or if the translations need a URL path like /de/:

php artisan cms:statamic-import --domain=example.com --file-base=https://example.com/assets --language=de:de:/de/ --language=fr:fr:https://example.fr/

The URL path of a site, like /de/, is added in front of the URLs of its translations. For site URLs with an Antlers host like https://{{ env:DE_HOST }}/, pass the domain explicitly, e.g. --language=de:de:https://example.de/. Translations whose URL is already used by another page are skipped with a warning.

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

Options

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

Option
Default
Description
--collections
pages
Collections to import, separated by commas
--fields
body,content,article,text,page_builder,page_sections,blocks
Entry fields that contain the content
--file-base
Base URL of the assets, for all containers or per container, e.g. images=https://cdn.example.com/images; repeatable
--container
The only container or assets
Asset container of asset values without a container
--site
First site or default
Statamic site imported as the source language
--language
Site imported as translation, e.g. de, de:de:/de/ or fr:fr:https://example.fr/; repeatable

Run the import again

Run the same command again to update the pages while editors still work in Statamic. With --since, only the entries changed since the date are imported, and the other pages stay as they are. Use the same options as before. If entries aren't imported any more, e.g. because they were deleted or became drafts, their pages are disabled. Pages changed in PagibleAI since the last import aren't overwritten. See Migrate to PagibleAI for the details.

Troubleshooting

No entries are found

The content is still stored in flat files, or the prefix of the connection doesn't match STATAMIC_ELOQUENT_PREFIX. Run the eloquent:import-* commands on a copy of the Statamic site and check the prefix.

Pages are empty

The content is stored in a field the importer doesn't read. Pass the field names of your blueprints with --fields.

Images are missing

The import ran without --file-base, so the asset URLs are unknown. Pass the base URL of the assets, per container if they differ, and import again.

Images have no alternative texts

The asset data wasn't moved into the database, or the Statamic version is older than 4.21. Run php please eloquent:import-assets on the copy of the Statamic site and import again.

Links to entries of another collection are missing

The collections were imported in separate runs, so the linked entries were unknown. Import all collections in one run.

Pages of another collection were disabled

Collections were imported in separate runs with the same --editor value. Import all collections in one run, or use a different --editor value for each run.