# Migrate from WordPress

> Import a WordPress site into Galerne from a WXR export file, and export Galerne content as a WXR file: options, how posts, pages, media, terms and authors map, and the losses.

The WordPress source reads the WXR file that WordPress writes in Tools, Export, with all content selected. It does not call the WordPress REST API.

## Import

```bash
galerne import --from wordpress --file ./example.WordPress.2026-10-17.xml --dry-run
galerne import --from wordpress --file ./example.WordPress.2026-10-17.xml
```

Options go after `--from` as flags in kebab case (`projectId` is `--project-id`). With the `import_from` tool, they go in `options`. See the [migration overview](/docs/migrate.md) for the shared flags, the report and re-runs.

| Option | What it is |
|---|---|
| `file` | The WXR file |
| `url` | The same file at a public URL (tools) |
| `data` | The same XML inline (tools) |
| `siteUrl` | The site address, to recognise internal links and images. Default: the one in the file |

## How content maps

| WordPress | Galerne |
|---|---|
| Posts, pages, custom post types | Document types `post`, `page` and so on; ids `<post type>-<WordPress id>` |
| Title, slug, excerpt, date | `title`, `slug` (when every slug is valid and unique, else a string), `excerpt`, `publishedAt` |
| Content (blocks or classic HTML) | `body` rich text |
| Featured image | `featuredImage` |
| Attachments | Media with alt text, title and caption; ids `wp-<id>` |
| Categories and tags | Documents, referenced from `categories` and `tags`; categories keep their parent |
| Authors | `person` documents, referenced from `author` |
| Sticky, parent, menu order | `sticky`, `parent`, `menuOrder` |
| Custom fields without a leading `_` | A `meta` object of text fields, with a warning |
| Links to the site, images from the media library | `doc:<id>` links, `media:<id>` images |
| Status `publish` | Published |

## What the import loses

The report lists each of these when it happens.

- Drafts, pending, private and scheduled posts come in as drafts, with a warning. Trash, auto-drafts and revisions are skipped, and so are menus and other system types.
- Comments are dropped, with their count in the report.
- Scripts, iframes, SVG and forms inside content are dropped. Images hosted elsewhere stay as they are, with a warning.
- Translation plugins (Polylang, WPML) are not read: each translation comes in as its own post.

## Export to WordPress

```bash
galerne export --to wordpress --out ./wp-export --site-url https://example.com
```

| Option | What it is |
|---|---|
| `siteUrl` | Site address written in the file, default `https://example.com` |
| `title` | Site title |
| `mediaBaseUrl` | Base URL of attachments. Default: relative `attachments/` paths |

The folder holds `export.xml` (WXR 1.2) for Tools, Import, the files under `attachments/`, and a `README.md`. Categories, tags and people become terms and authors.

The export loses:

- One version per document: the published version, with a warning when a newer draft exists.
- Only the fields WordPress has are written: title, slug, body, excerpt, date, author, featured image, categories, tags, sticky, parent, menu order and text custom fields. Other fields are left out.
- Languages are not written. The guidelines document is left out.
- Embeds in the body become `<div data-galerne-embed>` elements that hold the block as JSON. Your theme renders them; importing the file back turns them into embeds again.
