Virtual CardsPaymentsTechAI ToolsSEOSocial & TradeCryptoFree Resources

How to Enable IndexNow for Astro on Cloudflare

clouflare

To enable IndexNow for an Astro site on Cloudflare, there are two mainstream approaches: Cloudflare Crawler Hints (zero-code, automatic) and the astro-indexnow integration (auto-submit at build time).

Below are the complete setup steps.

Option 1: Cloudflare Crawler Hints (recommended, zero-code)

Cloudflare has built-in IndexNow support. Once enabled, it automatically pushes updates to Bing, Yandex and others — no Astro code changes needed.

1. Prerequisites

  • Your domain is connected to Cloudflare and resolving properly
  • Your Astro site is deployed to Cloudflare Pages/Workers

2. Enable Crawler Hints

  1. Log in to the Cloudflare Dashboard → go to your domain
  2. Left menu: Caching → Configuration
  3. Find Crawler Hints → enable Enable Crawler Hints
  4. Save the settings

Cloudflare automatically monitors content changes on your site and notifies search engines via the IndexNow protocol.

Option 2: astro-indexnow Integration (submit at build time, precise and controllable)

Use the official astro-indexnow integration to automatically submit changed URLs when Astro builds — ideal when you need precise control over submission timing.

1. Install the integration

# npm
npm install astro-indexnow --save-dev
# or use the Astro CLI
npx astro add astro-indexnow

2. Generate and host the IndexNow API Key

  1. Generate a Key: visit the IndexNow website to generate an API Key (e.g., 19ea3a37344a414fb6c09554549114a9)
  2. Create the Key file: in your Astro project's public/ directory, create a text file named [yourKey].txt whose content is just the Key itself
  3. Make sure it's accessible: after deployment, https://your-domain.com/[Key].txt should open normally

3. Configure Astro

Edit astro.config.mjs, add the astro-indexnow integration and configure the site and Key:

import { defineConfig } from 'astro/config';
import indexnow from 'astro-indexnow';

export default defineConfig({
  // 必须配置你的站点域名
  site: 'https://your-domain.com',
  integrations: [
    indexnow({
      // 你的 IndexNow API Key
      key: '19ea3a37344a414fb6c09554549114a9',
      // Key 文件路径(默认根目录,与 public 对应)
      keyLocation: '/19ea3a37344a414fb6c09554549114a9.txt',
      // 可选:提交引擎(默认 Bing、Yandex)
      engines: ['bing', 'yandex'],
    }),
  ],
});

4. Deploy to Cloudflare

  • Cloudflare Pages: Connect your Git repository, build settings:
    • Build command: npm run build
    • Output directory: dist
  • Cloudflare Workers: Install the @astrojs/cloudflare adapter, set output: ‘server’, and deploy with wrangler deploy

5. Verify the submission

  • Build logs: check the astro build output to confirm the submission succeeded
  • Bing Webmaster Tools: go to the IndexNow panel and review submission records

3. Comparing the Two Options

OptionProsConsBest for
Cloudflare Crawler HintsZero-code, automatic, free, no maintenanceSubmission timing not controllable; relies on Cloudflare monitoringQuick enablement, minimal setup
astro-indexnowPrecise build-time submission, only changed URLs, configurable enginesRequires installing the integration, configuring a Key and maintaining filesWhen precise control or multi-site management is needed