Skip to main content

Publish Google Docs to WordPress with advance RankMath SEO & Gemini analysis

Workflow preview

Workflow preview
100%
Publish Google Docs to WordPress with advance RankMath SEO & Gemini analysis preview
Open on n8n.io

Important notice

This workflow is provided as-is. Please review and test before using in production.

1. Workflow Overview

Who is this for? This workflow is designed for Content Marketing Teams, Agencies , and Professional Editors who prefer writing in Google Docs but need a sea...

Best for

  • Content Creation automation workflows
  • AI Summarization automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

n8n-nodes-base.httprequest, n8n-nodes-base.code, n8n-nodes-base.merge, n8n-nodes-base.if, n8n-nodes-base.set, @n8n/n8n-nodes-langchain.googlegemini, n8n-nodes-base.googledrive, n8n-nodes-base.googledrivetrigger

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Cuong Nguyen.

Original n8n.io source

1.1 Workflow description

Title
Publish Google Docs to WordPress with advance RankMath SEO & Gemini analysis
Workflow name
Publish Google Docs to WordPress with advance RankMath SEO & Gemini analysis

Who is this for?

This workflow is designed for Content Marketing Teams, Agencies, and Professional Editors who prefer writing in Google Docs but need a seamless way to publish to WordPress.

Unlike generic "AI Writers" that generate content from scratch (which often fails AI detection), this workflow focuses on "Document Ops"—automating the tedious task of moving, cleaning, and optimizing existing human-written content.

Why use this workflow? (The SEO Advantage)

Most automation templates leave your SEO score at 0/100 because they fail to map RankMath metadata. This workflow hits the ground running with an immediate 65-70/100 RankMath Score.

By using a Gemini AI Agent to analyze your content and mapping it to hidden RankMath API fields, it automatically passes these critical checks:

  • Focus Keyword in SEO Title: AI automatically inserts the target keyword at the beginning.
  • Focus Keyword in Meta Description: AI crafts a compelling description containing the keyword.
  • Focus Keyword in URL: AI generates a clean, short, keyword-rich slug.
  • Focus Keyword at the Start: The workflow intelligently injects a "hook" sentence containing the keyword at the very top of your post.
  • Content Length: Preserves your original long-form content.

How it works

  1. Monitors Google Drive: Watches for new HTML/Doc files in a specific "Drafts" folder.
  2. Cleans Content: Sanitizes raw HTML from Google Docs (removing messy styles and tags).
  3. Smart Duplicate Check: Checks if the post already exists on WordPress (via slug) to decide whether to Create a new draft or Update an existing one.
  4. AI Analysis (Gemini): Extracts the best Focus Keyword, SEO Title, and Meta Description from your content.
  5. RankMath Integration: Pushes these SEO values directly into RankMath's custom meta keys.
  6. Archiving: Moves processed files to a "Published" folder to keep your Drive organized.

Critical Prerequisites (Must Read)

To allow n8n to update RankMath SEO data and prevent 401 Unauthorized errors, you MUST add a helper snippet to your WordPress site.

  1. Access your WordPress files via FTP/File Manager.
  2. Navigate to wp-content/mu-plugins/ (Create the folder mu-plugins if it doesn't exist).
  3. Create a file named n8n-rankmath-helper.php and paste the following code:
<?php
/*
Plugin Name: n8n RankMath & Auth Helper
Description: Fixes Basic Auth Header for n8n and exposes RankMath meta keys to REST API.
*/

// 1. Fix Authorization Header (Solves 401 Errors on Apache/LiteSpeed)
add_filter('wp_is_application_passwords_available', '__return_true');
if ( !function_exists('aiops_enable_basic_auth') ) {
    function aiops_enable_basic_auth() {
        if ( isset( $_SERVER['HTTP_AUTHORIZATION'] ) ) {
            $auth = $_SERVER['HTTP_AUTHORIZATION'];
            if ( strpos( $auth, 'Basic ' ) === 0 ) {
                list( $username, $password ) = explode( ':', base64_decode( substr( $auth, 6 ) ) );
                $_SERVER['PHP_AUTH_USER'] = $username;
                $_SERVER['PHP_AUTH_PW']   = $password;
            }
        }
    }
    add_action('init', 'aiops_enable_basic_auth');
}

// 2. Expose RankMath Meta Keys to REST API
add_action( 'rest_api_init', function () {
    $meta_keys = [
        'rank_math_title',
        'rank_math_description',
        'rank_math_focus_keyword',
        'rank_math_robots',
        'rank_math_canonical_url'
    ];

    foreach ( $meta_keys as $meta_key ) {
        register_meta( 'post', $meta_key, [
            'show_in_rest' => true,
            'single'       => true,
            'type'         => 'string',
            'auth_callback' => function() { return current_user_can( 'edit_posts' ); }
        ] );
    }
});
?>;

How to set up

1. Configure Credentials:

  • Google Drive OAuth2 (Drive scopes).
  • Google Gemini (PaLM) API Key.
  • WordPress: Connect using Application Passwords (Users > Profile > Application Passwords).

2. Global Configuration (First Node):

  • Open the node named CONFIG - Edit Settings Here.
  • wp_base_url: Enter your site URL (e.g., https://your-site.com - no trailing slash).
  • drive_published_folder_id: Enter the ID of the Google Drive folder where you want to move published files.

3. Trigger Setup:

  • Open the Google Drive Trigger node.
  • Select your specific "Drafts" folder in the Folder to Watch field.

Future Roadmap

We are actively improving this template. Upcoming V2 will feature:

AI Featured Image Generation: Auto-create branded thumbnails.

Content Illustrations: Auto-insert relevant images into the body content.

Need Help or Want to Customize This?

Contact me for consulting and support: Email: [email protected]

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - HTTP Request (Export HTML)

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.3

Block 2 - Code (Extract Body)

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 3 - Code (Prepare Metadata)

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 4 - HTTP Request (WP - Find Post by Slug)

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.3

Block 5 - Merge (Meta + FindResult)

Type / Role
n8n-nodes-base.merge - merge
Config choices
Version 3.2

Block 6 - IF (Found Post?)

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2.3

Block 7 - HTTP Request: WP - Create Post

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.3

Block 8 - HTTP Request - WP Update Post

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.3

Block 9 - SET - SEO Input

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 10 - GEMINI - SEO JSON

Type / Role
@n8n/n8n-nodes-langchain.googleGemini - googleGemini
Config choices
Version 1

Block 11 - CODE - Parse & QA SEO

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 12 - HTTP - WP Update SEO (RankMath)

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.3

Block 13 - CODE - Build WP Payload

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 14 - HTTP - WP Get Post (Verify)

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.3

Block 15 - MERGE - Attach postId

Type / Role
n8n-nodes-base.merge - merge
Config choices
Version 3.2

Block 16 - Google Drive - Move to Published

Type / Role
n8n-nodes-base.googleDrive - googleDrive
Config choices
Version 3

Block 17 - Google Drive Trigger

Type / Role
n8n-nodes-base.googleDriveTrigger - googleDriveTrigger
Config choices
Version 1

Block 18 - CONFIG - Edit Settings Here

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 19 - Sticky Note

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 20 - Sticky Note1

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 21 - Sticky Note2

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 22 - Sticky Note3

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 23 - Sticky Note4

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 24 - Sticky Note5

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

3. Summary Table

Workflow Publish Google Docs to WordPress with advance RankMath SEO & Gemini analysis
Complexity advanced
Nodes 24
Categories Content Creation, AI Summarization
Author Cuong Nguyen
Published 20 Dec 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/11989/11989.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Publish Google Docs to WordPress with advance RankMath SEO & Gemini analysis do?

Who is this for? This workflow is designed for Content Marketing Teams, Agencies , and Professional Editors who prefer writing in Google Docs but need a sea...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Content Creation, AI Summarization use case.