GamendWeb.IndexNow (gamend_web v1.0.1215)

Copy Markdown View Source

Tells search engines a page changed, instead of waiting to be crawled.

IndexNow is a push protocol: one POST names the URLs that changed, and the receiving engine shares it with the others that participate. Submitting to any endpoint reaches all of them, so there is one endpoint setting and no per-engine fan-out.

Google does not participate. Bing, Yandex and Seznam do. This is worth being clear about before wiring it up: it will not move anything in Google Search Console, and it is not a substitute for a sitemap.

Setup

Generate a key — any 8–128 hex characters — and set:

GAMEND_INDEX_NOW_ENABLED=true
GAMEND_INDEX_NOW_KEY=2f7c1a...

Ownership is proven by serving the key back at https://host/<key>.txt, which GamendWeb.Plugs.IndexNowKey does automatically from the same setting. There is nothing to upload and no account.

What to submit

Only genuine changes. The protocol exists to save crawlers from polling, and an engine that finds resubmitted-but-unchanged URLs will discount the source — the same trust problem as an untruthful <lastmod>. mix gamend.sitemap.lastmod reports exactly which pages moved; that list is the intended input:

changed |> Enum.map(&url_for/1) |> GamendWeb.IndexNow.submit()

Submission is best-effort. A failure is logged and returned, never raised: search engines finding out late is not worth failing a deploy over.

Summary

Types

Why a submission did not happen, or did not succeed.

Functions

Whether change notifications are configured and on.

The configured key, or nil when unset or malformed.

The path the key file is served at, e.g. /2f7c1a.txt.

Submits changed URLs.

Whether a key meets the protocol's requirements: 8–128 hexadecimal characters. Rejecting a malformed key here turns a silent 403 from the endpoint into a log line at startup.

Types

error()

@type error() ::
  :disabled
  | :no_key
  | :invalid_key
  | {:status, pos_integer()}
  | {:request, term()}

Why a submission did not happen, or did not succeed.

Functions

enabled?()

@spec enabled?() :: boolean()

Whether change notifications are configured and on.

key()

@spec key() :: String.t() | nil

The configured key, or nil when unset or malformed.

key_path()

@spec key_path() :: String.t() | nil

The path the key file is served at, e.g. /2f7c1a.txt.

submit(urls)

@spec submit([String.t()]) :: :ok | {:error, error()}

Submits changed URLs.

URLs must be absolute and all on the same host — the protocol rejects a submission that mixes hosts, since the key only proves ownership of one. Returns :ok, or {:error, reason} when disabled, misconfigured, or the endpoint refused. Over 10000 URLs are sent in batches.

valid_key?(key)

@spec valid_key?(String.t()) :: boolean()

Whether a key meets the protocol's requirements: 8–128 hexadecimal characters. Rejecting a malformed key here turns a silent 403 from the endpoint into a log line at startup.