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
- Runs on a schedule (and can also be started manually) to begin an indexing check.
- Downloads the main sitemap.xml, parses it from XML to JSON, and extracts the list of content-specific sitemap URLs.
- 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).
- 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).
- 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.
- Waits a short random delay between requests and continues looping until all URLs have been checked.
Setup
- 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.
- Update the sitemap.xml URL in the initial HTTP Request step to point to your own website.
- 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).