Sitemap CLI

The Sitemap CLI is a powerful command-line interface for generating, validating, submitting, and monitoring XML sitemaps. Designed for developers and SEO professionals, it integrates seamlessly with CI/CD pipelines, headless CMS architectures, and automated deployment workflows.

💡 Quick Start

Run npx sitemap-cli init in your project root to scaffold a sitemap.config.json file and generate your first sitemap in under 30 seconds.

Overview

The CLI provides a unified interface to interact with the Sitemap.xml platform. It handles dynamic URL discovery, priority assignment, change frequency optimization, and direct submission to Google, Bing, and Yandex webmaster services.

Key capabilities include:

  • Zero-configuration crawling & sitemap generation
  • Real-time indexing API integration
  • Multi-domain & subdomain support
  • Structured data & hreflang mapping
  • CI/CD ready with exit codes & JSON output

Installation

npm / yarn

npm install -g @sitemap/cli
# or
yarn global add @sitemap/cli

Homebrew (macOS/Linux)

brew tap sitemap/tools
brew install sitemap-cli

Standalone Binary

Download the latest release for your platform from github.com/sitemap/cli/releases. Make the binary executable and add it to your PATH.

Authentication

The CLI requires an API token to access platform features like instant indexing and analytics. You can provide your token via environment variable, config file, or inline flag.

Environment Variable

export SITEMAP_TOKEN="sk_live_abc123xyz"
sitemap crawl https://example.com

Auth Command

sitemap auth login

This opens an interactive prompt that securely stores your token in ~/.config/sitemap/auth.json.

sitemap init

Scaffolds a configuration file and performs an initial shallow crawl to detect your site structure.

sitemap init --domain example.com --output ./public/sitemap.xml

Generates sitemap.config.json with default rules for robots.txt compatibility, changefreq defaults, and priority scaling.

sitemap crawl

Executes a full or incremental crawl of your website and generates a compliant XML sitemap.

FlagDescription
--deepEnable recursive crawling beyond first 100 URLs
--concurrencyNumber of parallel requests (default: 5)
--include-regexPattern to include specific routes
--exclude-regexPattern to filter out admin/checkout routes
--outputOutput path for generated sitemap

sitemap submit

Pushes your generated sitemap directly to search engine consoles and triggers instant indexing for new/updated URLs.

sitemap submit ./public/sitemap.xml --engines google,bing
--push-indexing --notify-webhooks

sitemap verify

Validates sitemap syntax, checks for broken links, verifies HTTP status codes, and ensures compliance with W3C/Sitemap protocol specifications.

sitemap verify ./sitemap.xml --strict --json > report.json

Configuration File

The CLI reads sitemap.config.json or sitemap.yaml from your project root. Key fields:

{
  "domain": "https://example.com",
  "crawling": {
    "concurrency": 8,
    "respectRobots": true,
    "ignorePatterns": ["/admin/", "/api/v1/*"]
  },
  "sitemap": {
    "type": "xml",
    "compression": "gzip",
    "splitAt": 50000
  },
  "submission": {
    "engines": ["google", "bing"],
    "instantIndexing": true
  }
}

Global Flags

FlagDescription
--verbose, -vEnable detailed console logging
--dry-runSimulate execution without writing files
--configPath to custom config file
--quietSuppress non-error output

Common Errors

ERR_TOKEN_EXPIRED

Your API token has expired. Run sitemap auth login to refresh credentials.

ERR_CRAWL_TIMEOUT

The crawler exceeded the default 300s limit. Increase via --timeout 600 or reduce concurrency to avoid rate limiting.

ERR_INVALID_CONFIG

Schema validation failed. Use sitemap verify --config-only to pinpoint missing or malformed fields.

Debugging & Logs

Enable debug mode by setting DEBUG=sitemap:* in your environment. The CLI writes detailed JSON logs to ~/.local/share/sitemap/logs/ by default. Use sitemap logs tail to stream them in real-time.

"}