How to Automatically Generate and Sync a Sitemap

If you’re running a self-hosted knowledgebase or web tool that doesn’t support automatic sitemap generation, this guide will show you how to automate sitemap creation and sync it to a publicly accessible path — perfect for submitting to Google Search Console and other search indexes.

We’ll cover:

  • Setting up sitemap generation using a free Node.js-based tool
  • Syncing the generated sitemap to a web-accessible path
  • Automating both tasks using Windows Task Scheduler

✅ Prerequisites

Make sure you have the following:

  • Windows server or PC where your knowledgebase is hosted
  • Node.js installed
  • FreeFileSync installed
  • Your site must be publicly accessible so search engines can crawl it (or at least accessible on your domain)

🔧 Step 1: Install the Sitemap Generator Tool

npm install -g sitemap-generator-cli

You can also run it without installing using npx, which we’ll do below.

🔄 Step 2: Create a Batch File to Generate Your Sitemap

  1. Open Notepad.
  2. Paste the following:
@echo off
echo Generating sitemap...

npx sitemap-generator-cli -f C:\Sitemap\sitemap.xml -c 20 -l https://www.yourdomain.com

echo Sitemap generated.
exit

Note: Replace the output path and URL with your actual setup.

  1. Save this as: generate_sitemap.bat

📂 Step 3: Set Up FreeFileSync to Sync the Sitemap to Your Web Server

  1. Open FreeFileSync.
  2. Set the source folder to where your sitemap is generated (e.g., C:\Sitemap\).
  3. Set the destination folder to a web-accessible path on the same domain as your site (e.g., C:\inetpub\wwwroot\www.yourdomain.com\).
  4. Save the sync configuration as: SITENAMESiteMapSync.ffs_batch

🗓️ Step 4: Create Two Scheduled Tasks

Because running both commands in the same batch file can sometimes cause issues, we will schedule them separately.

📌 Task 1: Generate the Sitemap

  1. Open Task Scheduler
  2. Create Task → General tab:
    • Name: Generate Sitemap
    • Run with highest privileges
    • Run whether user is logged on or not
  3. Trigger tab:
    • New → Daily at 1:00 AM
  4. Action tab:
    • Start a program → Point to: C:\Path\To\generate_sitemap.bat

📌 Task 2: Sync the Sitemap

  1. Create another task in Task Scheduler:
    • Name: Sync Sitemap to Web Server
    • Trigger: Daily at 1:05 AM
    • Action: "C:\Program Files\FreeFileSync\FreeFileSync.exe" "C:\Users\YourUser\Documents\SITENAMESiteMapSync.ffs_batch"

🔗 Step 5: Submit Your Sitemap to Search Engines

Once your sitemap is synced to a public path, like:

https://www.yourdomain.com/sitemap.xml

You can now submit that URL to:

✅ Summary

By breaking the automation into two separate scheduled tasks — one for sitemap generation and one for syncing to your web root — you avoid task timing issues and ensure your sitemap is always fresh and available to search engines.

This method is great for:

  • Self-hosted knowledgebases
  • Static sites
  • Internal documentation portals with public access

Need help? Contact us at contact@digitalforgesystems.com — we specialize in smart automation for IT workflows.

Similar Posts