Hawk.js CLI Documentation

Hawk.js provides a powerful CLI tool to automate sitemap generation and submission to search engines using various supported strategies. This guide will walk you through the commands, options, and best practices for using the Hawk.js CLI.


Getting Started

The CLI can be invoked using the hawk command once Hawk.js is installed globally or locally in your project.

hawk [options] [command]

Global Options

The following global options apply to all commands in the CLI:

OptionAliasDefaultDescription
--strategy-s(Required)The indexing strategy to use (see strategies below).
--include-iConfigured lookup patternsSpecify file patterns to include in sitemap generation.
--exclude-eConfigured ignore patternsSpecify file patterns to exclude from sitemap generation.
--prettify-pfalsePrettify the output of the generated sitemap.xml file for better readability.

Supported Strategies

Choose one of the following strategies by providing the corresponding number with the --strategy option:

Strategy NumberStrategy NameDescription
1IndexNowNotify search engines like Bing and Yandex about content changes.
2GWebMasterGenerate and submit sitemaps to Google Search Console.
3GWebMaster2Generate, submit sitemaps, and receive feedback from Google Search Console.
4GIndexPush content updates directly to Google via the Indexing API.

Commands

1. Generate Sitemap: genmap

The genmap command generates a sitemap based on the provided --include and --exclude patterns. Optionally, it can upload the generated sitemap to an FTP server.

hawk genmap [options]

Options for genmap

OptionAliasDefaultDescription
--commit-cfalseUpload the generated sitemap.xml file to the FTP server.

Example Usage

  1. Generate a sitemap without uploading:

    hawk genmap -i "src/**/*.html" -e "node_modules/**"
  2. Generate and upload a sitemap to the FTP server:

    hawk genmap -i "src/**/*.html" -c

2. Initialize Configuration: init

The init command initializes a default configuration file (hawk.config.js) in the root directory of your project.

hawk init

Example Usage

hawk init

Output:

🚀 Hawk.js configuration initialized.

3. Main Command

If no subcommand is provided, the CLI defaults to employing a strategy for sitemap generation and submission.

hawk [options]

Example Usage

  1. Use the IndexNow strategy:

    hawk -s 1

    Output:

    🚀 Hawk employing "IndexNow" strategy...
  2. Use the GWebMaster2 strategy

    hawk -s 3

    Output:

    🚀 Hawk employing "GWebMaster2" strategy...

FAQ: Common Questions

What happens if I don’t specify a strategy?

If no valid strategy is provided, the CLI will prompt you to choose one of the supported strategies.

â­• Must choose any one number from below:
1. IndexNow
2. G-WebMaster
3. G-WebMaster2
4. G-Index

Can I use multiple strategies in one command?

No. Each CLI invocation applies a single strategy. To use multiple strategies, run separate CLI commands.


Next Steps

Explore more about each strategy:


Keywords:

  • Hawk.js CLI
  • sitemap generation
  • command line tool
  • IndexNow
  • Google Webmaster
  • GWebMaster
  • Indexing API
  • FTP upload
  • CLI commands
  • strategy configuration