{"id":26811178,"url":"https://github.com/wagtail/wagtail-wordpress-import","last_synced_at":"2025-04-08T04:16:02.994Z","repository":{"id":39969831,"uuid":"402342844","full_name":"wagtail/wagtail-wordpress-import","owner":"wagtail","description":"A package for Wagtail CMS to import WordPress blog content from an XML file into Wagtail","archived":false,"fork":false,"pushed_at":"2025-03-17T20:05:21.000Z","size":723,"stargazers_count":51,"open_issues_count":28,"forks_count":18,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-30T01:05:05.076Z","etag":null,"topics":["import","wagtail","wordpress"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wagtail.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-09-02T08:16:00.000Z","updated_at":"2025-03-28T20:23:40.000Z","dependencies_parsed_at":"2023-02-16T15:00:31.994Z","dependency_job_id":"cdd612b4-39a8-4cb0-a6bc-a73fa3cacccb","html_url":"https://github.com/wagtail/wagtail-wordpress-import","commit_stats":{"total_commits":531,"total_committers":5,"mean_commits":106.2,"dds":"0.10734463276836159","last_synced_commit":"ec44ab5c0cf4fdbb989bf4af098be9768407bde3"},"previous_names":["wagtail/wagtail-wordpress-import"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wagtail%2Fwagtail-wordpress-import","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wagtail%2Fwagtail-wordpress-import/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wagtail%2Fwagtail-wordpress-import/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wagtail%2Fwagtail-wordpress-import/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wagtail","download_url":"https://codeload.github.com/wagtail/wagtail-wordpress-import/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247773719,"owners_count":20993639,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["import","wagtail","wordpress"],"created_at":"2025-03-30T01:05:29.283Z","updated_at":"2025-04-08T04:16:02.975Z","avatar_url":"https://github.com/wagtail.png","language":"Python","funding_links":[],"categories":["Tools"],"sub_categories":["Templates \u0026 Starter Kits"],"readme":"# Wagtail WordPress Import\n\n[![codecov](https://codecov.io/gh/torchbox/wagtail-wordpress-import/branch/main/graph/badge.svg?token=KFSTTxTGxZ)](https://codecov.io/gh/torchbox/wagtail-wordpress-import)\n\nA package for Wagtail CMS to import WordPress blog content from an XML file into Wagtail.\n\n- [Wagtail WordPress Import](#wagtail-wordpress-import)\n  - [Requirements](#requirements)\n  - [Compatibility](#compatibility)\n  - [Initial app and package setup](#initial-app-and-package-setup)\n    - [Site URL for importing images and documents](#site-url-for-importing-images-and-documents)\n    - [First steps to configure your Wagtail app](#first-steps-to-configure-your-wagtail-app)\n      - [A full example of the suggested page model class](#a-full-example-of-the-suggested-page-model-class)\n  - [Running the import command](#running-the-import-command)\n    - [Optional command arguments](#optional-command-arguments)\n  - [Import process flow](#import-process-flow)\n  - [Module documentation](#module-documentation)\n  - [Developer Tooling](#developer-tooling)\n  - [Further Usage Examples](#further-usage-examples)\n\n## Requirements\n\n1. Wagtail CMS Installed with initial setup\n2. WordPress XML export of all content in a single file\n3. The WordPress website will need to be live and available for importing of assets such as images and documents.\n\n## Compatibility\n\nThe package has been developed and tested with:\n\n- Wagtail: ^2.15\n- Django: ^3.1\n- Postgres and SQLite Databases\n\n`All code examples are for a site using Wagtail v3.0+` See [Wagtail release notes](https://docs.wagtail.org/en/stable/releases/3.0.html) for compatibility for Wagtail versions \u003c3.0\n\n## Initial app and package setup\n\n1. Setup a Wagtail site using your preferred method or follow the [official documentation](https://docs.wagtail.io/en/stable/getting_started/tutorial.html) to get started.\n2. Install this package from PyPi with `pip install wagtail-wordpress-import`\n or using any method you prefer.\n3. Place your XML files somewhere on your disk. The file can have any name you choose.\n4. Create a `log` folder in the root of your site. The import script will need to write report files to this folder, you may need to set the permissions on the folder.\n5. Add `\"wagtail_wordpress_import\"` to your INSTALLED_APPS config in your settings.py file.\n\n### Site URL for importing images and documents\n\nAdd a setting of `WAGTAIL_WORDPRESS_IMPORTER_SOURCE_DOMAIN` in your sites settings and set it to the the URL of the website that the images and documents will be imported from.\n\nThe importer uses the [requests](https://docs.python-requests.org/en/latest/) library to download images and documents during the import process using the configuration in  `WAGTAIL_WORDPRESS_IMPORTER_REQUESTS_SETTINGS`.\n\nIf the default settings are not suitable for your import, you can add the settings below to your own site settings and override the values.\n\n```python\n# import package default settings\n\nWAGTAIL_WORDPRESS_IMPORTER_REQUESTS_SETTINGS = {\n    \"headers\": {\"User-Agent\": \"WagtailWordpressImporter\"},\n    \"timeout\": 5,\n    \"stream\": True,\n    \"allow_redirects\": allow_redirects,\n}\n```\n\n### First steps to configure your Wagtail app\n\nThe import can be run on an existing or new site but you will need to perform some setup on your page models.\n\nWe recommend your page model inherits from the provided WPImportedPageMixin\n\n```python\nfrom wagtail_wordpress_import.models import WPImportedPageMixin\n\n\nclass PostPage(WPImportedPageMixin, Page):\n    ...\n```\n\nYou will need to run `python manage.py makemigrations` and `python manage.py migrate` to add the fields to your page model.\n\n*It's intended that these fields are temporary for while importing, and can be removed once the content has been imported. [view source](wagtail_wordpress_import/models.py)*\n\n#### A full example of the suggested page model class\n\nThe import default is to import the `post` and `page` content types to an app called `app` and a model called `PostPage`. Keep that mind when you create your own page model.\n\n```python\n# mysite/app/models.py\n# The imports below assume you are using Wagtail v3.0+\n\n# Wagtail \u003c 3.0\n# from wagtail.admin.edit_handlers (...)\nfrom wagtail.admin.panels import (\n    FieldPanel,\n    ObjectList,\n    TabbedInterface,\n)\n\n# Wagtail \u003c 3.0\n# from wagtail.core.fields import StreamField\nfrom wagtail.fields import StreamField\n\n# Wagtail \u003c 3.0\n# from wagtail.core.models import Page\nfrom wagtail.models import Page\n\nfrom wagtail_wordpress_import.blocks import WPImportStreamBlocks\nfrom wagtail_wordpress_import.models import WPImportedPageMixin\n\n\nclass PostPage(WPImportedPageMixin, Page):\n    body = StreamField(WPImportStreamBlocks)\n    content_panels = Page.content_panels + [\n        # Wagtail \u003c 3.0\n        # StreamFieldPanel(\"body\")\n        FieldPanel(\"body\"),\n    ]\n\n    edit_handler = TabbedInterface(\n        [\n            ObjectList(content_panels, heading=\"Content\"),\n            ObjectList(Page.promote_panels, heading=\"Promote\"),\n            ObjectList(Page.settings_panels, heading=\"Settings\", classname=\"settings\"),\n            ObjectList(WPImportedPageMixin.wordpress_panels, heading=\"Debug\"),\n        ]\n    )\n\n    def import_wordpress_data(self, data):\n        # Wagtail page model fields\n        self.title = data[\"title\"]\n        self.slug = data[\"slug\"]\n        self.first_published_at = data[\"first_published_at\"]\n        self.last_published_at = data[\"last_published_at\"]\n        self.latest_revision_created_at = data[\"latest_revision_created_at\"]\n        self.search_description = data[\"search_description\"]\n\n        # debug fields\n        self.wp_post_id = data[\"wp_post_id\"]\n        self.wp_post_type = data[\"wp_post_type\"]\n        self.wp_link = data[\"wp_link\"]\n        self.wp_raw_content = data[\"wp_raw_content\"]\n        self.wp_block_json = data[\"wp_block_json\"]\n        self.wp_processed_content = data[\"wp_processed_content\"]\n        self.wp_normalized_styles = data[\"wp_normalized_styles\"]\n        self.wp_post_meta = data[\"wp_post_meta\"]\n\n        # own model fields\n        self.body = data[\"body\"]\n```\n\n## Running the import command\n\nThe most basic command would be:\n\n```bash\npython manage.py import_xml path/to/xml/file.xml parent_page_id\n```\n\n`parent_page_id` is the ID of the page in your Wagtail site where WordPress pages will be imported as children. You can find this in the Wagtail admin URL when editing the page e.g. for `http://www.domain.com/admin/pages/3/edit/` the ID is 3.\n\nRunning this command will import all WordPress 'post' and 'page' types to the 'PostPage' model in an app called 'pages'\n\nYou can run the import as many times as you need. To avoid content duplication, subsequent imports after the first import will update the existing pages. This behavior also applies to any images or documents that have been imported.\n\n### Optional command arguments\n\n- `-m` can be used to specify the Wagtail Page model to use for all imported pages. The default is `PostPage` when it's not specified.\n- `-a` can be used to specify the Wagtail App where you have created your Wagtail Page model. The default is `pages` when it's not specified.\n- `-t` can be used to limit the WordPress page types to be imported. You can pass in a comma-separated string of page types or just a single page type. The default is `page,post` if not specified.\n- `-s` can be used to specify the status of pages you want to import. You can pass in a comma-separated string of statuses or just a single status. The default is `publish,draft` if not specified.\n\n## Import process flow\n\nWhile the import process is simple to run with the options above there's a lot that happens during the import.\n\nBy changing the import configuration, you can customise the import process without modifying `wagtail-wordpress-import` package files. To understand what is possible, and how you can change the behaviour at different stages, you can read an [overview of the import process](docs/import_process.md).\n\n## Module documentation\n\n- [Block Builder](docs/blockbuilder.md)\n- [Categories Import](docs/categories.md)\n- [Import Hooks](docs/import_hooks.md)\n- [Prefilters](docs/prefilters.md)\n- [WordPress Block Shortcodes](docs/block_shortcodes.md)\n- [WordPress Inline Shortcodes](docs/inline_shortocdes.md)\n- [Yoast Import](docs/yoast.md)\n\n## Developer Tooling\n\nWe have included some developer commands to help you with importing large datasets and analyzing the data.\n\n[View Developer Tooling](docs/tooling.md)\n\n## Further Usage Examples\n\n- [Handling Specific HTML content structures](docs/examples.md)\n\n## Contributing\n\nIf you're a Python or Django developer, fork the repo and get stuck in!\n\nYou might like to start by reviewing the [contributing guidelines](https://github.com/torchbox/wagtail-wordpress-import/wiki/Contributing-to-the-package) in the wiki and checking [current issues](https://github.com/torchbox/wagtail-wordpress-import/issues).\n\n## Releases\n\n[Realease process](https://github.com/torchbox/wagtail-wordpress-import/wiki/Create-a-new-release)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwagtail%2Fwagtail-wordpress-import","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwagtail%2Fwagtail-wordpress-import","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwagtail%2Fwagtail-wordpress-import/lists"}