goodmorning/craft-indexnow
Composer 安装命令:
composer require goodmorning/craft-indexnow
包简介
IndexNow integration for Craft CMS
README 文档
README
IndexNow integration for Craft CMS.
This plugin automatically (or programmatically) notifies participating search engines when content on your site changes, so they can crawl and update search results faster.
What is IndexNow?
IndexNow is an open protocol originally backed by Microsoft Bing and Yandex.
Instead of waiting for search engines to discover changed content via periodic crawling, your site pushes a small JSON payload listing new / updated / deleted URLs. Benefits:
- Faster reflection of fresh or removed content
- Reduced unnecessary crawl load
- Lightweight (simple POST with JSON)
- Privacy-friendly (you choose what to send)
The core endpoint used (by default) is: https://api.indexnow.org/indexnow, which proxies to participating engines.
Features
- 🔑 Automatic key verification route:
https://your-site/<apiKey>.txt - 🛰️ URL submission service with retry & logging
- 🧪 Dry run mode for safe testing (no external HTTP requests)
- 🌐 Environment gating (only activate on selected environment)
- 🧩 Twig extension (exposes settings for templates)
- 🛠️ Control panel utility (
Utilities > IndexNow) - 👤 Permission: restrict access to plugin settings (
indexnow-accessSettings) - 🧾 Optional request payload logging (for audits / debugging)
- 🔌 Endpoint override (point to a mock server or future protocol changes)
Requirements
- Craft CMS 5.7.0+
- PHP 8.2+
- OpenSSL / cURL enabled (default Craft HTTP stack requirements)
- Outbound HTTPS allowed to
api.indexnow.org(or your override)
Installation
From the plugin store (recommended)
- In the control panel, go to plugin store → search for “indexnow”.
- Click install.
Via Composer
# From your Craft project root
composer require goodmorning/craft-indexnow
php craft plugin/install craft-indexnow
Configuration & settings
You can configure settings in the control panel (Settings → Plugins → IndexNow) or optionally via a config file override (config/indexnow.php).
Current settings (based on code)
| Setting | Type | Default | Description |
|---|---|---|---|
apiKey |
string | (none) | Secret key used both for verification file route and payload authentication. Required for submissions. |
environment |
string | production |
Environment name in which the plugin should actively initialize URL submission logic. |
logPayload |
bool | false |
If true, logs the full JSON payload prior to sending (use with caution in production). |
dryRun |
bool | false |
If true, skips the outbound HTTP request but logs as if it would submit (useful for testing). |
endpointOverride |
string | (empty) | Alternate IndexNow endpoint (e.g. staging / mock server). If set, plugin logs the override. |
Config file example (config/indexnow.php)
Create this file if you’d like to lock or override settings from code (these values will typically override CP-edited values depending on how your Settings model is implemented):
<?php return [ 'apiKey' => App::env('INDEXNOW_API_KEY'), 'environment' => 'staging,production', 'logPayload' => false, 'dryRun' => false, 'endpointOverride' => null, ];
Make sure to add INDEXNOW_API_KEY to your .env:
INDEXNOW_API_KEY=your-generated-key
Key verification file
Once the apiKey is saved, the plugin dynamically registers a route:
https://your-domain/<apiKey>.txt
This route should return the key content — search engines request it to verify ownership.
Test it after saving the key:
curl -i https://example.com/YOURKEYVALUE.txt
Expect: HTTP/1.1 200 OK and body containing the key.
Usage
Automatic Submission
This plugin listens for element events and collects URLs to send. Ensure only public, canonical URLs are submitted (avoids drafts / revisions).
Manual submission (programmatic)
From custom module / template / console command:
use goodmorning\craftindexnow\IndexNow; /** @var \goodmorning\craftindexnow\services\SendUrls $sender */ $sender = IndexNow::getInstance()->sendUrls; $sender->sendUrls([ 'https://example.com/articles/new-thing', 'https://example.com/articles/another-thing', ]);
The service will:
- Build payload (
host,key,urlList) - Optionally log payload
- POST JSON to endpoint (with retry on transient connect issues)
- Log success or failure
Dry run mode
Enable dryRun to validate integration without network side effects.
The plugin:
- Builds & logs payload
- Skips HTTP request
- Logs: “IndexNow dry run enabled: not sending HTTP request.”
Use this in early staging or while finalizing API key ownership.
Endpoint override
Useful for:
- Mock servers
- Future protocol changes
- Internal relay / firewall
Set endpointOverride to a full URL. Logged on use:
Using IndexNow endpoint override: https://internal-mock/index
Troubleshooting
| Problem | Possible Cause | Resolution |
|---|---|---|
| Verification file 404 | API key not saved, route cache not cleared | Re-save settings, flush caches |
| “API key is not set” error | Missing key | Add key in settings or config file |
| Repeated failures sending | Network firewall / blocked endpoint | Test with curl, whitelist domain |
| Payload logs missing | logPayload is false |
Enable in settings temporarily |
| Works in dev, not in prod | Environment mismatch | Check CRAFT_ENVIRONMENT and environment setting |
| Duplicate submissions | Entry events fired multiple times (e.g., drafts) | Add guards in EntryService (publish status, duplicates suppression) |
Security considerations
- Avoid enabling
logPayloadlong-term in production; logs may reveal content timing. - Treat
endpointOverridecarefully — don’t point to untrusted hosts.
Roadmap / ideas
- Configurable batch size and debounce window
- Console command:
php craft indexnow/send <url> - Resend last N changed entries from Utility
- Multiple environment support
- Metrics panel (success vs failure counts)
(Open issues / PRs are welcome.)
Changelog
See CHANGELOG.md for release history (add entries there before tagging).
License
Distributed under the Craft license (or update this if you choose another).
See LICENSE.md.
Support
- Email: tech@goodmorning.no
- Issues: (add GitHub issues URL once public)
Quick start
- Install plugin
- Set API key
- Hit
https://site/<apiKey>.txtto verify - Ensure environment matches (
CRAFT_ENVIRONMENT) - Save / update content
- Check logs for “Successfully sent URLs to IndexNow.”
Happy indexing!
goodmorning/craft-indexnow 适用场景与选型建议
goodmorning/craft-indexnow 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 10 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 08 月 28 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「search」 「seo」 「craftcms」 「indexnow」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 goodmorning/craft-indexnow 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 goodmorning/craft-indexnow 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 goodmorning/craft-indexnow 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Expand, collapse, change the status of, or delete multiple blocks in a Matrix field simultaneously.
A Laravel package to retrieve data from Google Search Console
GraphQL authentication for your headless Craft CMS applications.
Indexed Search Autocomplete - Extends the TYPO3 Core Extension Indexed_Search searchform with an autocomplete feature.
Supercharged text field validation.
Help to manage meta data on Laravel Eloquent model
统计信息
- 总下载量: 10
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 23
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: proprietary
- 更新时间: 2025-08-28