This n8n workflow automates the process of generating and updating Yoast SEO metadata for WordPress pages using Google Gemini AI. Instead of manually writing SEO titles and meta descriptions for every page, the workflow fetches the page content, generates SEO-friendly metadata with AI, updates the Yoast SEO fields through the WordPress REST API, and logs the results in Google Sheets for future reference.
How the Workflow Works
The workflow begins with a Manual Trigger, making it easy to execute whenever a page needs SEO optimisation.
1. Set Configuration
The first Set node stores the required configuration values, including:
-
WordPress website URL
-
WordPress Page ID
This allows the workflow to dynamically fetch and update any page without modifying multiple nodes.
2. Fetch the WordPress Page
An HTTP Request node connects to the WordPress REST API using basic authentication. It retrieves the complete page details, including:
-
Page title
-
Page content
-
Existing metadata
The workflow requests the page in edit context to ensure all editable fields are available.
3. Prepare the Content
A second Set node extracts the important information from the API response.
During this step, the workflow:
-
Retrieves the page title
-
Removes HTML tags from the page content
-
Cleans unnecessary whitespace
-
Prepares a plain-text version of the content for AI processing
This ensures the AI receives clean, readable content instead of raw HTML.
4. Generate SEO Metadata with Google Gemini
The cleaned title and content are sent to the AI Agent node powered by the Google Gemini Chat Model.
A custom system prompt instructs Gemini to generate:
-
An SEO title (maximum 60 characters)
-
A meta description (maximum 155 characters)
The prompt also includes best practices such as:
-
Place the primary keyword near the beginning.
-
Write naturally without clickbait.
-
Keep the title concise and readable.
-
Create a compelling meta description that summarizes the page and encourages users to click.
5. Structured Output Validation
The workflow uses an Output Parser node to enforce a predefined JSON structure.
This guarantees that Gemini always returns:
-
seo_title -
meta_description
Using structured output reduces parsing errors and makes the workflow much more reliable.
6. Prepare the Update Payload
Another Set node formats the generated SEO title and meta description into the payload expected by the WordPress REST API.
The workflow maps the generated values directly to the Yoast SEO custom fields.
7. Update Yoast SEO Fields
A second HTTP Request node sends a POST request back to WordPress.
It updates:
-
Yoast SEO Title (
_yoast_wpseo_title) -
Yoast Meta Description (
_yoast_wpseo_metadesc)
This means the SEO metadata is written directly into Yoast SEO without any manual editing inside the WordPress dashboard.
8. Log Results to Google Sheets
Finally, the workflow appends a new row to Google Sheets containing:
-
Page URL
-
Page Name
-
Generated Slug
-
SEO Title
-
Meta Description
This provides a simple audit log, making it easy to review all generated SEO metadata later.
Nodes Used
-
Manual Trigger
-
Set (Configuration)
-
HTTP Request (Fetch WordPress Page)
-
Set (Prepare Content)
-
AI Agent
-
Google Gemini Chat Model
-
Structured Output Parser
-
Set (Prepare API Payload)
-
HTTP Request (Update Yoast SEO)
-
Google Sheets (Append Row)
Benefits
-
Eliminates repetitive manual SEO work.
-
Generates consistent, SEO-friendly metadata.
-
Uses AI to create optimized titles and descriptions.
-
Updates Yoast SEO automatically through the WordPress REST API.
-
Keeps a complete history of generated metadata in Google Sheets.
-
Can easily be adapted for posts, products, or custom post types with minimal changes.
This workflow demonstrates how n8n can combine AI, APIs, and WordPress automation to streamline SEO tasks. It is especially useful for websites with a large number of pages, posts, products any anything in YOAST. helping content teams save time while maintaining consistent, high-quality metadata across the entire site.
I’d really appreciate any suggestions or feedback you may have.