Export and Import
Move a CanAI site design between sites as one JSON file, from wp-admin, MCP or WP-CLI.
What it is
An export is a portable JSON backup of your CanAI work. Use it to move a design from a staging site to production, keep a restore point before big changes, or copy a build to a second site.
An export contains:
- Templates, with their HTML, CSS, JS, context and template vars, and their template types.
- Pages that have a Twig body (
_canai_html), including their paths, and any precompiled Tailwind build. - Options: default layout, stylesheet and Tailwind settings, saved queries, and the multilingual settings, string table and media map.
- A
media_warninglist of attachment IDs the content references. Media files are not included, so re-map or re-upload them on the target.
Pages written as blocks (wpcanai/write-page, or create-page with format: "blocks") are not in the bundle yet.
The file records wpcanai_export_version (currently 1.1), the time and the source site URL.
Export and import from wp-admin
- Open CanAI → Tools → Export / Import.
- Under Export, click Download export file (.json).
- On the other site, open the same page, choose the file under Import, and click Preview import.
- Check the preview, then click Run import.
From an agent (MCP)
// wpcanai/export (summary:true returns ids, titles and hashes, no content)
{ "summary": true }
// wpcanai/import (dry_run previews without writing)
{ "json": "<the bundle as a string>", "dry_run": true }
import accepts the bundle as data (an object) or json (a string, tolerant of stray text around it).
From WP-CLI
wp wpcanai export /tmp/canai-export.json
wp wpcanai import /tmp/canai-export.json --dry-run
wp wpcanai import /tmp/canai-export.json
The dry run prints the counts (templates created and updated, pages updated and skipped) without touching the database.
How import matches things
- Templates are matched by slug and created or updated.
- Pages are updated, never created. In a 1.1 bundle a page is matched by its full path, so
/gallery/theatrettes/never overwrites a top-level/theatrettes/. Create the pages on the target first (wpcanai/create-page), then import. - Older bundles (exported before CanAI 1.97) have no paths. They match by slug, and only when exactly one page on the site has that slug.
- The default layout and template delegate pages are matched the same way, by reference rather than by ID.
If something looks wrong
Every skipped item comes back as a warning in the import result.
- "CanAI page not found at path gallery/theatrettes (skipped)." No page sits at that path on this site. If a page with the same slug lives elsewhere, the warning says where. Move it with
wpcanai/update-page, then import again. - "Slug … matches 2 pages (…); export again from CanAI 1.97+ so the bundle carries paths." An old bundle with an ambiguous slug. Export again from a current CanAI.
- "CanAI page not found on this site (skipped)". The page does not exist on the target yet. Create it, then re-run.
- "Delegate page not found for template …". The template is imported, but without its delegate page. Create the page and import again.
- "Invalid JSON". The file should start with
{and hold one JSON object. Re-download the export; turn offdisplay_errorsif PHP notices leaked into the download. - Images missing after import. Check
media_warningin the bundle and re-upload those files, or usewpcanai/sideload-url. - Page lists differ between sites. Run the content scan afterwards (
link_unresolved,link_moved) to catch links to pages that did not come across.