See llms.txt for all machine-readable content.

Back to Templates

Index website pages in Google Search with sitemaps and Indexing API

Quick overview

This workflow runs on a schedule (or manually) to fetch your website’s sitemap URLs, compare each page’s last modified date with Google Indexing API metadata, and submit URL_UPDATED requests for new or recently changed pages using Google OAuth2.

How it works

  1. Runs on a schedule (and can also be started manually) to begin an indexing check.
  2. Downloads the main sitemap.xml, parses it from XML to JSON, and extracts the list of content-specific sitemap URLs.
  3. Fetches each content-specific sitemap, parses it, normalizes the urlset.url structure to an array, splits out individual pages, and sorts pages by lastmod (newest first).
  4. For each page URL, queries the Google Indexing API metadata endpoint to get the latest notification time (or an error if it has never been submitted).
  5. Submits a Google Indexing API publish request with type URL_UPDATED when the page’s lastmod is after Google’s latest notifyTime or when the metadata lookup fails.
  6. Waits a short random delay between requests and continues looping until all URLs have been checked.

Setup

  1. Create a Google Cloud project with the Indexing API enabled, then add a Google OAuth2 credential in n8n that has permission to call the Indexing API.
  2. Update the sitemap.xml URL in the initial HTTP Request step to point to your own website.
  3. Ensure your sitemap entries expose loc and lastmod fields (or adjust the mapping step that assigns lastmod and loc to match your CMS sitemap schema).