WT-1469: Add management commands for importing WordPress blog posts - #1627
Open
StuartMacKay wants to merge 171 commits into
Open
WT-1469: Add management commands for importing WordPress blog posts#1627StuartMacKay wants to merge 171 commits into
StuartMacKay wants to merge 171 commits into
Conversation
Adds two management commands: 1. import_wordpress_blog_posts, which parses the WordPress export XML into BlogArticlePage entries (topics, tags, authors, images, and content blocks). 2. import_wordpress_redirects, which creates Redirect records from the CSV the import command produces. Also adds an Author snippet model with a BlogArticlePage.author field and ?author= filtering on the blog index, plus tests for all of the above.
StuartMacKay
marked this pull request as ready for review
July 23, 2026 11:01
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1627 +/- ##
==========================================
+ Coverage 88.55% 89.30% +0.75%
==========================================
Files 177 178 +1
Lines 12386 13109 +723
==========================================
+ Hits 10968 11707 +739
+ Misses 1418 1402 -16 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Editors can pick topics and tags on the Blog Options panel to keep their articles out of automatic feeds. get_feed_exclusions() resolves the field to translation keys
Both listing routes accept ?tag=<slug> alongside the existing ?topic=.
Feed exclusions always apply, except to the single topic or tag the reader explicitly selected: ?topic=X spares X, ?tag=Y spares Y, and a topic page spares its own topic.
BlogLatestArticlesBlock lists N latest articles BlogCardsListSourceBlock lists N articles from a topic or tag BlogArticleSectionValue is populated by the index page, which handles the querying logic to guarantee that articles don't show up twice on the blocks.
Drop fields that populated the "More Articles" section and implement the logic for the new "Article Sections". The index page queries the articles for each block, excluding the ones already displayed from the next block's filter.
Posts whose ImageFeatured is blank still attach their header image, so the first ImageURL entry becomes the hero instead of the post importing with no image at all - which also left its cards imageless on the index and related article lists. Claude-Session: https://claude.ai/code/session_01Pjpe9S6YPcmAqQtVB68erJ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
One-line summary
Import Wordpress blog posts, exported from blog.mozilla.org, into Wagtail CMS.
Significant changes and points to review
This pull request adds two management commands:
import_wordpress_blog_posts, which parses the WordPress export XML into BlogArticlePage entries (topics, tags, authors, images, and content blocks).
import_wordpress_redirects, which creates Redirect records from the CSV the import command produces.
Also adds an Author snippet model with a BlogArticlePage.author field and ?author= filtering on the blog index, plus tests for all of the above.
Issue / Bugzilla link
https://mozilla-hub.atlassian.net/browse/WT-1469
Testing
These two commands import the WordPress blog export into Wagtail. Test them locally against mozilla-blog-posts.xml.
IMPORTANT: If you want to test using Docker you will have to modify
Dockerfileto copy the xml file so the management commands can access it. Insert the follwing starting at line 107Import the blog posts
Confirms the file parses cleanly and shows what would be imported, without writing anything.
Runs the import for real. Look for a final summary line like:
Any failures are logged per-post to stderr and don't stop the rest of the import.
Verify in the Wagtail admin:
Re-run to check idempotency:
Should report 0 imported, 68 skipped, 0 failed — no duplicate pages created.
Create redirects from the old WordPress URLs
The first command writes wordpress_redirects.csv (old permalink → new page). Use it to create Wagtail redirects:
Shows what redirects would be created.
Creates the redirects for real.
Verify in the Wagtail admin: