/publish-draft command publishes draft articles to WordPress as drafts, automatically populating all SEO metadata fields.
Usage
Path to the draft file (in
drafts/ or rewrites/)Post type:
post (blog post), page (WordPress page), or custom post typeExamples
Post Types
- post (default)
- page
- Custom Post Types
Standard blog postFeatures:
- Supports categories and tags
- Chronological feed
- Author attribution
- Published as draft by default
What It Does
Parses Draft File
Extracts all metadata from frontmatter:
- Meta Title
- Meta Description
- Primary Keyword (Target Keyword)
- Secondary Keywords
- URL Slug
- Categories
- Tags
Converts Markdown to HTML
- Converts markdown formatting to HTML
- Preserves headings (H1-H6)
- Maintains links and formatting
- Converts lists and code blocks
Creates WordPress Draft
Posts via REST API:
- Status:
draft(never auto-publishes) - Title: H1 from article
- Content: Full HTML content
- Slug: From frontmatter
- Author: Current WordPress user
Sets Yoast SEO Fields
Automatically populates:
- SEO Title (Meta Title)
- Meta Description
- Focus Keyphrase (Primary Keyword)
- Canonical URL (if specified)
Assigns Taxonomy
If specified in frontmatter:
- Categories (creates if don’t exist)
- Tags (creates if don’t exist)
Metadata Mapping
- Content Fields
- Yoast SEO Fields
- Taxonomy
| Draft Field | WordPress Field |
|---|---|
| H1 Title | Post Title |
| Body Content | Post Content (HTML) |
| URL Slug | Post Slug |
Setup Requirements
Environment Variables
Add to.env file:
Getting an Application Password
Create New Password
- Enter name: “SEO Machine”
- Click “Add New Application Password”
- Copy the generated password
WordPress Plugin
Install the Yoast SEO REST API MU-plugin:
See
wordpress/README.md for detailed setup instructions.
Adding Categories & Tags
To assign categories or tags, add to draft frontmatter:Categories and tags are created automatically if they don’t exist in WordPress.
Process
Output
Successful publish returns:Troubleshooting
WORDPRESS_URL must be set
WORDPRESS_URL must be set
Problem: Environment variables not configuredSolution:
- Create
.envfile in root directory - Add WordPress credentials:
- Verify
.envis in.gitignore
401 Unauthorized
401 Unauthorized
Could not find category
Could not find category
Problem: Category doesn’t existSolution: Categories are created automatically. If error persists:
- Check category name for special characters
- Manually create category in WordPress first
- Verify REST API is enabled for categories
Yoast fields not populated
Yoast fields not populated
Problem: Yoast SEO REST API not exposedSolution:
- Install MU-plugin:
wordpress/seo-machine-yoast-rest.php - Verify Yoast SEO plugin is active
- Check
functions.phpsnippet is added - Test REST API endpoint:
/wp-json/wp/v2/posts
Custom post type not found
Custom post type not found
Problem: Custom post type not registered or REST API not enabledSolution:
- Verify custom post type exists in WordPress
- Check registration includes
'show_in_rest' => true - Test endpoint:
/wp-json/wp/v2/[post-type]
Important Notes
Images are NOT uploaded - only text content is transferred. Upload images manually in WordPress after publishing.
Multiple runs create multiple drafts - Running the command twice creates two separate draft posts.
WordPress Integration
SEO Machine uses the WordPress REST API with a custom MU-plugin for Yoast SEO integration.Architecture
Files
wordpress_publisher.py
Python module that handles REST API callsLocation:
data_sources/modules/wordpress_publisher.pyseo-machine-yoast-rest.php
MU-plugin that exposes Yoast SEO fields to REST APILocation:
wordpress/seo-machine-yoast-rest.phpfunctions-snippet.php
Additional theme functions for REST API supportLocation:
wordpress/functions-snippet.phpREADME.md
Detailed WordPress setup instructionsLocation:
wordpress/README.mdTips
Test First
Test with a simple article first to verify setup.
Review in WordPress
Always review and preview drafts before publishing live.
Upload Images
Add images manually in WordPress after publishing draft.
Check Yoast
Verify Yoast SEO fields populated correctly in WordPress.
Related Commands
/optimize
Optimize before publishing
/write
Create articles to publish