This guide provides a step-by-step process to migrate the content from your WordPress site to the Sonata Extra Bundle.
Step 1: Content Import
Start by importing your WordPress content using the following command
bin/console sonata-extra:wordpress-importer --url https://www.domain.com --user wordpressUser --token "[APPLICATION_PASSWORD]"
For detailed instructions on this command, refer to the dedicated guide: WordPress import order
After executing this command, your WordPress categories, tags, and posts should be successfully imported.
Step 2: Viewing the articles
You can now view your articles using the blog routes provided by Sonata.
Step 3: Translation Setup
To translate content into multiple languages, follow these steps:
- Set up your OpenAI account:
Refer to the Translation API documentation to configure your OpenAI account. Alternatively, you can use your custom provider or choose not to use a translation API.
- API Configuration:
Update the Sonata Extra pack configuration to include your translation API settings:
partitech_sonata_extra:
translation_api:
translate_on_create_page: true
translate_on_create_translation: true
default_provider: open_ai
providers:
open_ai:
class: Partitech\SonataExtra\Translation\Provider\OpenAiProvider
api_key: '%open_ai_api_key%'
model: '%open_ai_api_model%'
max_token_per_request: 200
Define open_ai_api_key and open_ai_api_model in your file .env.
Choose a model supported by the configured provider, then validate the quality, cost, and maximum request size on a representative sample. Avoid locking a model name in the guide that may disappear.
Enable automatic translation: Add the attribute #[Translatable] and import Partitech\SonataExtra\Attribute\Translatable in the properties of your entity for automatic translation.
Step 4: Translation of the content
Run the following commands to translate your content (you may want to add your own services):
bin/console sonata:extra:translate-content --site=2,3,4,5 --reference-site=1 --service="sonata.classification.admin.category"
bin/console sonata:extra:translate-content --site=2,3,4,5 --reference-site=1 --service="sonata.classification.admin.tag"
bin/console sonata:extra:translate-content --site=2,3,4,5 --reference-site=1 --service="Partitech\SonataExtra\Admin\ArticleAdmin"
bin/console sonata:extra:translate-content --site=2,3,4,5 --reference-site=1 --service="Partitech\SonataExtra\Admin\EditorAdmin"
bin/console sonata:extra:translate-content --site=2,3,4,5 --reference-site=1 --service="sonata.page.admin.page"
Note: If the translation process gets stuck, just restart the process, and it will resume where it left off.
Step 5: menu setup
If you have not set up your menu yet, it is recommended to first duplicate the default menu.
-
Duplicate the menu: Manually duplicate the default menu. Note that the tree structure will not be preserved and must be reorganized manually.
-
Menu URL correction:
Run the following command to fix the URLs of the menu items:
bin/console sonata:extra:fix-menu-url --menu=6
This command will adjust the URLs to match the localized pages in SonataPage.
Step 6: Creating snapshots
Finally, create snapshots of your pages with the command:
bin/console sonata:page:create-snapshots
Secure the switch

Freeze a content window, replay the import on a recent copy, and prepare a redirection table between old and new URLs. The procedure must cover volumes, media, authors, SEO metadata, and internal links before the DNS switch.