Skip to content

AdelMahjoub/Index-Now-Script

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

IndexNow Sitemap Submitter

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.


Features

  • Environment Variable Configuration - Sensitive information like the host, key, and sitemap URL are now stored in a separate .env file, 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.

Requirements

  • Node.js 16+
  • npm

Installation

  1. Clone the repository:
    git clone https://github.com/yourusername/indexnow-sitemap-submitter.git
    cd indexnow-sitemap-submitter
  2. Install dependencies:
    npm install
  3. Create the IndexNow key file:
    • Run the command npm run key to generate a 32-character hexadecimal key.
    • Save the key in a .txt file at your site's root as https://yourdomain.com/<your-key>.txt.
    • The content of this file should be only the key itself.

Configuration

  1. Create a .env file in the project's root directory based on the provided .env.example.
  2. Populate the .env file 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.

Usage

  1. Run the script:

    npm start
  2. The script will:

    • Parse your sitemap.
    • Compare it with indexedUrls.json.
    • Submit only the new URLs.
    • Save the updated list to indexedUrls.json.

Example

npm start

Output:

200
{ "message": "URLs submitted successfully" }

Notes

  • The first run will submit all URLs in your sitemap.
  • indexedUrls.json will 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 .txt file.

About

Simple Node.js utility to submit URLs to IndexNow from a sitemap, with automatic duplicate filtering and URL tracking.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors