A simple Node.js script that:
- Fetches all URLs from a site's sitemap (including sitemap indexes).
- Compares them against previously submitted URLs.
- Submits new URLs to the IndexNow API.
- Keeps track of already indexed URLs in a JSON file.
Perfect for quick deployment on any site to speed up indexing in Bing, Yandex, and other IndexNow-supported search engines.
- Environment Variable Configuration - Sensitive information like the host, key, and sitemap URL are now stored in a separate
.envfile, keeping your code clean and secure. - Automatic sitemap parsing - Works with both simple and sitemap-index.xml formats.
- Duplicate filtering - Only new URLs are submitted.
- Batch submission - Sends multiple URLs in one API call.
- JSON tracking - Stores previously indexed URLs in
indexedUrls.json. - Reusable template - Clone and configure for any site in seconds.
- Node.js 16+
- npm
- Clone the repository:
git clone https://github.com/yourusername/indexnow-sitemap-submitter.git cd indexnow-sitemap-submitter - Install dependencies:
npm install
- Create the IndexNow key file:
- Run the command
npm run keyto generate a 32-character hexadecimal key. - Save the key in a
.txtfile at your site's root ashttps://yourdomain.com/<your-key>.txt. - The content of this file should be only the key itself.
- Run the command
- Create a
.envfile in the project's root directory based on the provided.env.example. - Populate the
.envfile with your specific information:HOST="lemanenergie.fr" SEARCH_ENGINE="https://api.indexnow.org/indexnow" KEY="6b9ef652127a4b62f4b064cd213eb6ed" SITEMAP="https://lemanenergie.fr/sitemap-index.xml"
- HOST: Your domain name (e.g.,
yourdomain.com). - SEARCH_ENGINE: The IndexNow API endpoint (should be
https://api.indexnow.org/indexnow). - KEY: The 32-character hexadecimal key you generated.
- SITEMAP: The URL to your sitemap or sitemap index file.
- HOST: Your domain name (e.g.,
-
Run the script:
npm start
-
The script will:
- Parse your sitemap.
- Compare it with
indexedUrls.json. - Submit only the new URLs.
- Save the updated list to
indexedUrls.json.
npm startOutput:
200
{ "message": "URLs submitted successfully" }
- The first run will submit all URLs in your sitemap.
indexedUrls.jsonwill be created automatically if missing.- IndexNow does not work with Google Search — only with participating search engines.
- Key verification may take a few minutes after uploading the
.txtfile.