Publier un brouillon sur WordPress (SEO)
/publish-draftPublie un brouillon d'article issu de ce projet sur WordPress en tant que brouillon, avec toutes les métadonnées SEO renseignées automatiquement.
Publish Draft to WordPress
Publishes a draft article from this project to WordPress as a Draft, with all SEO metadata auto-populated.
Usage
/publish-draft [filename] [--type post|page|custom]
Examples
Create a blog post (default):
/publish-draft drafts/content-marketing-guide-2025-12-10.mdCreate a page:
/publish-draft drafts/pricing-comparison.md --type pageCreate a custom post type:
/publish-draft drafts/product-comparison.md --type comparePost Types
post- Standard blog post (default) - supports categories and tagspage- WordPress page - no categories/tags- Custom types (e.g.,
compare) - must be registered in WordPress with REST API support
What This Command Does
- Parses the draft file - Extracts all metadata from frontmatter
- Converts Markdown to HTML - Formats content for WordPress
- Creates WordPress draft - Posts via REST API with status "draft"
- Sets Yoast SEO fields:
- SEO Title (from Meta Title)
- Meta Description
- Focus Keyphrase (from Target Keyword)
- Assigns taxonomy - Categories and Tags if specified
- Returns edit URL - Direct link to edit the post in WordPress
Metadata Mapping
| Draft Field | WordPress/Yoast Field |
|---|---|
| H1 Title | Post Title |
| Meta Title | Yoast SEO Title |
| Meta Description | Yoast Meta Description + Excerpt |
| Target Keyword | Yoast Focus Keyphrase |
| URL Slug | Post Slug |
| Category | Post Categories |
| Tags | Post Tags |
| Content | Post Content (HTML) |
Required Environment Variables
These must be set in .env:
WORDPRESS_URL=https://yoursite.com
WORDPRESS_USERNAME=your-username
WORDPRESS_APP_PASSWORD=xxxx-xxxx-xxxx-xxxxGetting an Application Password
- Log into WordPress Admin
- Go to Users > Your Profile
- Scroll to "Application Passwords"
- Enter a name (e.g., "SEO Machine")
- Click "Add New Application Password"
- Copy the generated password to your
.envfile
Process
When you run this command:
Step 1: Validate File
- Confirm the draft file exists
- Parse metadata and content
- Display extracted fields for confirmation
Step 2: Publish to WordPress
Run the WordPress publisher:
cd /path/to/seomachine
python data_sources/modules/wordpress_publisher.py "$FILE_PATH" --type "$POST_TYPE"Where $POST_TYPE is post, page, or a custom post type.
Step 3: Confirm Success
Display the WordPress edit URL so the user can review and publish.
Optional: Add Categories/Tags
To assign categories or tags, add these fields to your draft frontmatter:
**Category**: [Your Category]
**Tags**: [your topic], beginner, getting startedMultiple categories/tags are comma-separated.
Troubleshooting
"WORDPRESS_URL must be set"
Add credentials to .env file. See Required Environment Variables above.
"401 Unauthorized"
- Verify username is correct
- Regenerate Application Password
- Ensure user has permission to create posts
"Could not find category"
The category will be created automatically if it doesn't exist.
Notes
- Posts are always created as drafts (never published automatically)
- The H1 heading from the article becomes the WordPress post title
- Images/media are not uploaded - only text content is transferred
- You can run this command multiple times on the same file (creates new drafts each time)