- Stable
3.0.0
Toggle Menu
1.93s
22.90s
Migrating from WordPress to Eleventy
Use @11ty/import
Eleventy provides a command line tool to import various data sources to projects as static content files.
This importer accepts a number of different types of import sources—in this example we’ll use a WordPress blog home page URL. This will convert all of the posts (via the WordPress REST API) from that blog to static content files in your local project.
> npx @11ty/import wordpress https://example.com/
Wrote 141 documents and 810 assets (933 cleaned, unused) from WordPress (7 errors) in 2.14 seconds (v1.0.0)
The importer will:
- Import the post content to the file system maintaining the same URL structure (change the root directory with
--output
) - Download all of the assets referenced in that content to your project (so that you can version them in
git
, for example) and change the reference URLs in the markup to point to those files. - Will not overwriting existing content (unless using the
--overwrite
option) so that you can repeat the same import command to only fetch new content. - All downloads are cached locally so that you can stop and resume a large import without losing your import progress (using the Eleventy Fetch plugin).
- Optionally convert the content to Markdown.
Try it out with --dryrun
first to be safe!
Alternatively, use a WordPress Export File
If you would like to permanently escape the WordPress ecosystem, you can do a one-time export of your content via the Admin panel of your WordPress site. At time of writing this feature exists in the WordPress sidebar in Tools → Export → Export content (section) → Export all (button).
This will create a compressed XML file with all of your posts (drafts included) for download. You can optionally also export your media library, but that is unnecessary for the purposes of this guide.
You can use lonekorean/wordpress-export-to-markdown
to convert your exported XML file to markdown files (or another similar tool). This tool will also download any media from your post and page content too.
Now you can place these markdown files in your Eleventy input directory and we’ll build them for you! If you use the Image transform plugin, we’ll optimize your images automatically too!
WordPress XML Export to Markdown Tools
Community Resources
Resources via 11tybundle.dev (Migrating to Eleventy) curated by Bob Monsour.