Automated Internal Linking Strategy with SerpAPI and Google Sheets - n8n Workflow

Boost your SEO by automatically finding internal linking opportunities using this practical n8n workflow. Connect Google Sheets and SerpAPI to generate link suggestions efficiently.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Ideal User Persona

SEO Specialists and Content Managers: Professionals focused on improving website structure and search engine rankings.
Website Owners: Individuals running large blogs or e-commerce sites needing systematic internal link auditing.
n8n Users: Anyone looking for practical n8n templates that combine external API data extraction (SerpAPI) with database management (Google Sheets).
Automation Enthusiasts: Those seeking a sophisticated n8n workflow demonstration involving looping, batching, and conditional data processing.

Overview

Internal linking is a cornerstone of effective SEO, helping search engines crawl your site and establishing topical authority. Manually identifying relevant pages that should link to a new target URL is time-consuming. This powerful n8n workflow eliminates that manual effort.

This n8n template automates the process by taking a list of target URLs and keywords from a Google Sheet. It uses the SerpAPI to perform targeted, site-specific searches, ensuring that the results are relevant internal pages (excluding the target page itself). By providing this comprehensive list of potential source pages, this n8n automation allows SEO teams to focus purely on implementation, drastically improving the efficiency of internal linking strategy.

Running this repeatable n8n workflow ensures your linking strategy remains consistent and up-to-date.

How it Works

This efficient n8n workflow is designed for sequential processing and high reliability:


  1. Start: The process begins with a manual n8n trigger, initiating the entire n8n workflow upon command.

  2. Data Retrieval (Get URLs and keywords n8n node): The n8n workflow connects to the designated Google Sheet to fetch a list of target pages, associated keywords, and the domain. Crucially, it filters out any rows where internal link suggestions have already been found (Internal link 1 column is not empty), preventing duplicate processing in subsequent runs.

  3. Batch Processing (Loop Over Items n8n node): The retrieved URLs are processed in manageable batches (configured to 5), optimizing performance and reducing the risk of rate limiting on external APIs like SerpAPI. This is a vital flow control step within the n8n template.

  4. Search API Request (Get search results using SerpAPI n8n node): For each URL, an HTTP Request is sent to SerpAPI. The search query uses interpolation to dynamically construct a precise Google search: site: -inurl:. This request asks Google to find pages on your site related to the keyword, while explicitly excluding the page you are currently optimizing.

  5. Data Extraction (Extract links from JSON n8n node): The complex JSON response from SerpAPI is simplified. This n8n node extracts only the list of organic_results links, preparing them for insertion into the spreadsheet.

  6. Data Update (Add internal URL to Google Sheet n8n node): The final step updates the original Google Sheet. Using the URL as the matching key, the n8n workflow writes up to ten found internal link opportunities into dedicated columns (Internal link 1, Internal link 2, etc.). It uses conditional logic (if statements) to insert "N/A" if fewer than ten links are found, ensuring the data remains clean and predictable.

Installation Guide

To deploy and run this powerful n8n workflow, follow these setup steps:


  1. Import the n8n Workflow: Copy the provided JSON data and import it into your n8n instance using the 'New' > 'Import from JSON' function.

  2. Google Sheets Setup: You need a Google Sheet containing at least columns for Domain, URL, and Keyword. Create the columns Internal link 1 through Internal link 10 where the results will be written.

  3. Credentials Setup (Google Sheets): Configure your Google Sheets credential in n8n. Select the appropriate spreadsheet ID and sheet name within the 'Get URLs and keywords' and 'Add internal URL to Google Sheet' n8n nodes.

  4. Credentials Setup (SerpAPI): Obtain an API key from SerpAPI. Create a new SerpAPI credential within your n8n environment and link it to the 'Get search results using SerpAPI' n8n node.

  5. Activation: Once credentials and document IDs are set, activate the n8n workflow and execute the Manual n8n trigger to begin processing your internal linking suggestions.

Node Details

This n8n workflow leverages several core n8n node types to achieve its goal:

Manual Trigger (n8n trigger): The starting point of the n8n workflow, allowing manual initiation of the data process.
Google Sheets (Get URLs and keywords n8n node):
Function: Reads input data (URL, Keyword, Domain) and filters out already processed rows.
Key Configuration: Operation set to read, with a UI filter checking if the column Internal link 1 is empty.
Split In Batches (Loop Over Items n8n node):
Function: Controls the flow by splitting the incoming list of URLs into batches of 5, crucial for rate limit management.
Key Configuration: Batch Size set to 5.
HTTP Request (Get search results using SerpAPI n8n node):
Function: Executes the targeted search query against Google via SerpAPI to find related internal pages.
Key Configuration: URL set to https://serpapi.com/search. Query parameter q uses expressions: = {{$json.Keyword}} site:{{$json.Domain}} -inurl:{{$json.URL}}.
Set (Extract links from JSON n8n node):
Function: Transforms the data by extracting and mapping the link properties from the nested organicresults array.
Key Configuration: Uses a map function to capture the list of URLs: = {{$json.organicresults.map(item => item.link)}}.
Google Sheets (Add internal URL to Google Sheet n8n node):
Function: Updates the input sheet with the discovered internal linking opportunities.
Key Configuration: Operation set to update. Uses expressions like = {{ $json.organicresults[0] ? $json.organicresults[0] : "N/A"}} to conditionally insert data or "N/A" into the output columns.

Related n8n Workflows

Free

Nodes: 6 Nodes
Updated: December 26 2025
View all
Created by

Hi, I'm Robin. I'm a veteran marketer of 7 years and love automation. If you have any questions about automation feel free to reach out to me on LinkedIn: https://www.linkedin.com/in/rgeuens/

Featured*