How to Build an AI-Powered Internal Linking Workflow with n8n
Internal linking is one of the most underrated on-page SEO levers — yet most SEO teams treat it as an afterthought. Manually identifying opportunities across hundreds of pages is time-consuming, inconsistent, and prone to being skipped during busy content sprints. But what if you could build an automated workflow in n8n that scans your existing content, suggests contextually relevant internal links, and even drafts the anchor text — all without a developer? In this guide, you will learn exactly how to do that using n8n, OpenAI, and a few lightweight integrations.
Why Internal Linking Matters for SEO Automation
Internal links pass PageRank, establish topical authority, and guide both users and search engine crawlers through your site architecture. According to multiple SEO studies, pages with strong internal link equity consistently outperform those that are orphaned or under-linked. Despite this, internal linking remains one of the most manually intensive SEO tasks — it requires reading content, identifying semantic relationships, and making editorial judgments at scale.
This is precisely where automation shines. By using n8n to orchestrate a pipeline that reads your WordPress posts, extracts key topics via an LLM, and then cross-references them against your full content library, you can surface internal link opportunities in minutes rather than hours. The result is a repeatable, scalable process that improves with every new piece of content you publish.
Prerequisites: What You Need Before Building
Before building the workflow, make sure you have the following ready:
- n8n instance — self-hosted or n8n Cloud. Version 1.x or later is recommended.
- WordPress site with REST API enabled and an Application Password created for authentication.
- OpenAI API key — you will use GPT-4o or GPT-3.5-turbo for semantic topic extraction and anchor text generation.
- Google Sheets or Airtable — optional, for storing and reviewing suggestions before applying them.
Step 1 — Fetch All Published Posts from WordPress
The first node in your n8n workflow should be an HTTP Request node targeting your WordPress REST API. Use a GET request to https://yoursite.com/wp-json/wp/v2/posts?per_page=100&status=publish&_fields=id,title,slug,content,excerpt. Authenticate using Basic Auth with your WordPress username and Application Password.
If your site has more than 100 posts, add a Loop Over Items node that increments the page parameter and continues fetching until the response returns fewer items than the page size. This ensures your workflow captures the entire content library, not just the most recent batch.
Stripping HTML for Cleaner LLM Prompts
Raw WordPress post content is full of HTML markup, shortcodes, and block comments. Before sending content to OpenAI, use a Code node with a simple JavaScript regex to remove HTML tags and normalize whitespace. This reduces token usage significantly and improves the quality of LLM outputs:
Step 2 — Extract Key Topics with OpenAI
With clean text in hand, pipe each post through an OpenAI node (or HTTP Request node calling the Chat Completions API). Use a system prompt that instructs the model to return a JSON array of 3 to 7 core topics or target keywords for the given article. For example: “You are an SEO analyst. Given the following article content, extract between 3 and 7 primary topics or semantic keywords that best describe what this article is about. Return only a valid JSON array of strings, with no additional commentary.”
Set the model temperature to 0.2 for consistent, deterministic outputs. Parse the JSON response in a subsequent Code node and attach the topic array to each post object. After this step, every post in your workflow carries a structured list of its core themes — the raw material for finding linking opportunities.
Step 3 — Cross-Reference Posts for Linking Opportunities
Now comes the core logic. Using a Code node, iterate over every post and compare its topic array against the topic arrays of all other posts. A simple overlap detection — counting how many topics two posts share — gives you a relevance score. Posts with a score of 2 or higher are strong internal link candidates.
Build a data structure like this for each post: { sourcePostId, sourcePostTitle, targetPostId, targetPostTitle, targetPostSlug, overlapScore, sharedTopics }. Filter out pairs where a link from source to target already exists by searching the source post’s raw content for the target post’s slug. The result is a clean list of genuinely missing internal link opportunities.
Generating Anchor Text with GPT
For each opportunity pair, call OpenAI again with a targeted prompt: “Given that we are linking from an article titled ‘[SOURCE TITLE]’ to one titled ‘[TARGET TITLE]’, suggest 3 natural anchor text options that would fit contextually. Return a JSON array of strings.” This gives editors ready-to-use anchor text options rather than requiring them to craft copy from scratch, dramatically reducing the time from suggestion to implementation.
Step 4 — Output Suggestions to Google Sheets or Airtable
Rather than automatically injecting links into WordPress — which carries editorial risk — route the output to a review layer. Use n8n’s native Google Sheets node or Airtable node to append each suggestion as a row with columns for: Source Post, Target Post, Target URL, Overlap Score, Shared Topics, and Suggested Anchor Texts.
This creates an editorial queue that an SEO manager or content writer can review weekly. They can mark rows as “Applied,” “Rejected,” or “Needs Review.” For teams that want full automation, you can add an additional workflow step that reads approved rows and patches the WordPress post content via the REST API’s PUT /wp/v2/posts/{id} endpoint, inserting the link directly into the post body.
Step 5 — Scheduling and Maintenance
Set up a Schedule Trigger node to run this workflow weekly — ideally on Monday mornings so the team starts the week with fresh internal linking recommendations. As your content library grows, the number of suggestions will increase organically. Add deduplication logic to your Code node to avoid surfacing the same suggestion repeatedly once it has already been acted upon.
You can also trigger the workflow via a Webhook node that fires whenever a new post is published in WordPress, using the WordPress action post_published forwarded through a plugin like WP Webhooks. This way, every new article immediately gets its internal link opportunities surfaced — closing the gap between publishing and linking in real time.
Advanced Enhancement: Semantic Embeddings for Better Matching
The topic-overlap approach described above is fast and effective, but it relies on keyword matching rather than true semantic understanding. For larger sites or more sophisticated teams, consider upgrading the matching layer to use OpenAI text embeddings. Generate an embedding vector for each post’s clean text using the text-embedding-3-small model, store vectors in a lightweight database like Supabase with the pgvector extension, and then compute cosine similarity scores at matching time.
Semantic embeddings catch relationships that keyword overlap misses — for example, an article about “crawl budget optimization” is semantically related to one about “JavaScript rendering and Googlebot,” even if they share no exact keyword phrases. This upgrade meaningfully improves recommendation quality on content-rich sites.
Measuring the Impact of Your Internal Linking Automation
Once the workflow is running and links are being applied, track impact through Google Search Console. Monitor changes in impressions and clicks for the target posts over a 30 to 60 day window after new internal links are added. Posts that were previously under-linked often see measurable improvements in crawl frequency and organic visibility within a few weeks of receiving additional internal link equity.
You can close the loop entirely by building a second n8n workflow that pulls GSC data via the Search Console API, compares performance before and after linking actions, and reports results back to your Google Sheet. This turns your internal linking operation into a fully measurable, data-driven SEO system — not just a task on someone’s checklist.
Conclusion
Automating internal linking with n8n and AI is one of the highest-ROI SEO workflows you can build. It requires no coding expertise beyond basic JavaScript in Code nodes, runs entirely on your own infrastructure, and produces actionable recommendations that compound in value as your content library grows. Start with the basic version described here — fetch posts, extract topics, cross-reference, output to a spreadsheet — and iterate from there. Within a few workflow iterations, you will have a production-grade internal linking system that would take a manual SEO team hours to replicate each week.
