{
  "id": "245a3433-b139-4cc8-8bd2-b609d841fcf1",
  "name": "Sitemap Health Audit",
  "nodes": [
    {
      "parameters": {
        "content": "# Reviewed Harshith.com template\n\nReads one sitemap from a site you own, identifies a URL set or sitemap index, counts bounded locations, flags duplicates and reports invalid XML shape. It does not submit or alter a sitemap.\n\nThis export is inactive and contains no credentials, deployment IDs, webhook IDs, or pinned data. Review the visible URL before each run.",
        "height": 300,
        "width": 430,
        "color": 7
      },
      "id": "ee2fb9e6-07f6-4346-910b-03fee01a56ad",
      "name": "Read Me First",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -760,
        -300
      ]
    },
    {
      "parameters": {},
      "id": "b40150f8-9710-4f06-9525-684b7aedc783",
      "name": "Run Manually",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        -620,
        80
      ]
    },
    {
      "parameters": {
        "jsCode": "return [{ json: { url: 'https://www.harshith.com/sitemap.xml', maxUrlsToInspect: 5000 } }];"
      },
      "id": "e781c849-8832-4db3-87fe-3988ad6b84be",
      "name": "Set Sitemap URL",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -380,
        80
      ]
    },
    {
      "parameters": {
        "url": "={{ $json.url }}",
        "options": {
          "timeout": 15000,
          "redirect": {
            "redirect": {
              "followRedirects": false
            }
          },
          "response": {
            "response": {
              "fullResponse": true,
              "neverError": true,
              "responseFormat": "text"
            }
          }
        }
      },
      "retryOnFail": true,
      "maxTries": 3,
      "waitBetweenTries": 1000,
      "id": "8de0cf41-d124-4412-b62e-f3a8c096c4d1",
      "name": "Read Sitemap",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -100,
        80
      ]
    },
    {
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "const payload = $json;\nconst source = $('Set Sitemap URL').first().json;\nconst xml = String(payload.body || payload.data || '');\nconst xmlWithoutComments = xml.replace(/<!--[\\s\\S]*?-->/g, '');\nconst rootSource = xmlWithoutComments.replace(/^\\uFEFF/, '').replace(/^\\s*<\\?xml[\\s\\S]*?\\?>/i, '').trim();\nconst rootMatch = rootSource.match(/^<(urlset|sitemapindex)(?=[\\s>])/i);\nconst documentType = rootMatch ? rootMatch[1].toLowerCase() : 'invalid';\nconst rootClosed = documentType !== 'invalid' && new RegExp(`<\\/${documentType}\\s*>\\s*$`, 'i').test(rootSource);\nconst looksLikeSitemap = documentType !== 'invalid' && rootClosed;\nconst allLocations = [...xmlWithoutComments.matchAll(/<loc>([\\s\\S]*?)<\\/loc>/gi)].map((match) => match[1].trim()).filter(Boolean);\nconst locations = allLocations.slice(0, source.maxUrlsToInspect);\nconst duplicates = locations.filter((url, index) => locations.indexOf(url) !== index);\nconst truncated = allLocations.length > source.maxUrlsToInspect;\nreturn { json: { sitemapUrl: source.url, statusCode: Number(payload.statusCode || 0), documentType, rootClosed, locationCount: locations.length, urlCount: documentType === 'urlset' ? locations.length : 0, childSitemapCount: documentType === 'sitemapindex' ? locations.length : 0, duplicateCount: new Set(duplicates).size, truncated, looksLikeSitemap, needsReview: Number(payload.statusCode || 0) !== 200 || !looksLikeSitemap || locations.length === 0 || duplicates.length > 0 || truncated, checkedAt: new Date().toISOString() } };"
      },
      "id": "8e7514b2-d259-4d26-a773-ae344cbec7c3",
      "name": "Build Sitemap Report",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        180,
        80
      ]
    }
  ],
  "connections": {
    "Run Manually": {
      "main": [
        [
          {
            "node": "Set Sitemap URL",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Sitemap URL": {
      "main": [
        [
          {
            "node": "Read Sitemap",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read Sitemap": {
      "main": [
        [
          {
            "node": "Build Sitemap Report",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1",
    "saveDataErrorExecution": "none",
    "saveDataSuccessExecution": "none",
    "saveManualExecutions": false,
    "executionTimeout": 60
  },
  "tags": []
}
