Index Now submits requests to search engines when content (nodes /
taxonomy terms) has been created, updated or deleted on your website.
The module provides a service that you can use to send more requests
according to your needs.
The submodule Index Now Commerce extends the main module to also handle
commerce stores and products.

Supported search engines:

  • Amazon
  • IndexNow
  • Microsoft Bing
  • Naver
  • Seznam.cz
  • Yandex
  • Yep

Note: Since November 2021, compatible search engines immediately share all
submitted URLs with every other compatible search engine.
This means that if you choose to notify one search engine,
you notify every other one in the same time.

Requirements

This module requires Config split
in order to activate it only on a production environment.

Installation

Install as you would normally install a contributed Drupal module. Visit
https://www.drupal.org/node/1897420 for further information.

For commerce stores and products you also need to enable the
index_now_commerce sub-module.

Configuration

Go to /admin/config/services/index_now and choose the default search engine
you want to interact with.
You can also exclude content types, taxonomy vocabularies and/or commerce
stores/products types for which you don't want to use Index Now.

This module has to be used only on a production environment (search engines
can't crawl your local machine and there is no reason to index a preprod env).

After configuring Index Now (/admin/config/services/index_now), you need to
define a configuration for your production environment.
Go to admin/config/development/configuration/config-split, add a configuration
split setting if you don't have already one for your production environment,
then add a directory path for this config and enable "Index Now" in the
"Complete split" > "Modules" section.
Don't forget to export your configuration after submitting the form.

An API key has been generated for you when you installed/updated the module.
You can override the API key value if needed in your settings(.local).php:

$config['index_now.settings']['api_key'] = 'whatever-you-want';

If your site needs to index under a specific URL (for example, in a headless
CMS), you may specify an override in your settings(.local).php:

// All internal routes will be indexed using https://example.com as base url.
$settings['index_now.base_url'] = 'https://example.com';

When this setting is configured, the API key verification file must be served
by the public domain. Drupal cannot serve it there automatically, so you must
create it manually. First, retrieve your API key:

drush config:get index_now.settings api_key

Then create the following file on your public domain:

  • Filename: index_now_api_key_{your-api-key}.txt
  • Content: {your-api-key}

Important: $settings['index_now.base_url'] only replaces the scheme and
host of the URL submitted to search engines — it does not alter the path. The
URL path structure must be identical on both your internal Drupal domain and
the public domain. For more complex URL transformations, use
hook_index_now_url_alter — see the Hooks section below.

Service

The module provides a service that can be used to index other URLs than just
nodes, taxonomy terms and commerce stores/products pages:

\Drupal::service('index_now.indexnow')->sendRequest($your_url);

Note: $your_url must be an absolute URL hosted on your website.

Hooks

The module exposes two hooks, documented in index_now.api.php.

hook_index_now_url_alter(&$url, $context)

Alter the URL submitted to search engines before it is sent. Useful when your
frontend uses a different path structure than Drupal (e.g. headless CMS). The
$context array may contain an entity key holding the entity that triggered
the ping, allowing you to build the public URL based on entity type, bundle, or
any other property:

function example_index_now_url_alter(string &$url, array $context): void {
  $entity = $context['entity'] ?? NULL;
  if ($entity instanceof \Drupal\node\NodeInterface) {
    $url = 'https://example.com/' . $entity->bundle() . '/' . $entity->id();
  }
}

hook_index_now_key_location_url_alter(&$key_location)

Alter the URL of the API key verification file sent to search engines. Useful
when the key file is served from a different location than the base URL (e.g.
a CDN):

function example_index_now_key_location_url_alter(string &$key_location): void {
  $key_location = 'https://cdn.example.com/index_now_api_key_abc123.txt';
}

Drush command

In case you would need to regenerate the API key you can use the drush command:
drush index_now:keygenerate or its alias drush indnowkeygen

Maintainers

Current maintainers:

Supporting organizations: 
The idea of developing this module was brought up by Spiriit and part of version 1.0.x was developed on my working hours in agreement with the company

Project information

Releases