WordPress 外贸站排查
noindex和robots冲突,不能只看 SEO 插件。要同时查线上robots.txt、页面 HTML 里的 robots meta、HTTP Header 里的X-Robots-Tag、WordPress 阅读设置、SEO 插件和主题代码;否则产品页可能被误挡,thank-you 页又未必真正去索引。
这篇不再重复 robots.txt、noindex、canonical 的基础定义。
只讲 WordPress 外贸站怎么排查冲突。
先列 URL 意图,不要直接改规则
先把页面分成三类:
| 页面类型 | 期望状态 | 常见错误 |
|---|---|---|
| 首页 | 可抓取、可索引 | 上线后遗留全站 noindex |
| 产品分类页 | 可抓取、可索引 | 被 robots 误挡 /product-category/ |
| 产品详情页 | 可抓取、可索引 | 单页 SEO 设置误加 noindex |
| FAQ 页 | 可抓取、可索引 | 插件把页面归成低价值页 |
| 案例页 | 可抓取、可索引 | 主题模板输出了错误 robots meta |
| About / Factory | 可抓取、可索引 | 多语言目录被 robots 误挡 |
| RFQ 说明页 | 通常可抓取、可索引 | 和提交接口混在一起被拦 |
| Thank-you 页 | 可抓取但 noindex |
只在 robots 里 Disallow |
| 站内搜索页 | 通常 noindex |
被当成内容页进入索引 |
| 后台、客户资料、报价文件 | 权限保护 | 错误依赖 robots 或 noindex |
外贸站最怕两种事故:
该进索引的产品页被 noindex;该保护的客户资料只靠 robots.txt。
第一步:查线上 robots.txt
先看真实线上文件,不要只看后台插件预览:
SITE="https://www.example.com"
curl -sS "$SITE/robots.txt" | \
sed -n '1,200p'
再筛重点行:
curl -sS "$SITE/robots.txt" | \
grep -Ein \
'user-agent|disallow|allow|sitemap|googlebot|bingbot|wp-admin|wp-content|noindex'
重点排查这些危险写法:
User-agent: *
Disallow: /
User-agent: *
Disallow: /products/
Disallow: /product-category/
Disallow: /faq/
还有一种老问题:在 robots.txt 里写 Noindex:。
Google 现在不支持把 Noindex: 当作可靠 robots.txt 指令。需要控制索引,应使用页面 robots meta 或 X-Robots-Tag。
第二步:查页面 HTML 里的 robots meta
选几个外贸核心 URL 抽样:
PAGE="https://www.example.com/products/industrial-valve/"
curl -sS -L "$PAGE" | \
grep -Ein \
'<meta[^>]+name=["'"'"']robots["'"'"']|noindex|nofollow|canonical'
如果公开产品页里出现:
<meta name="robots" content="noindex, nofollow">
那就要回 WordPress 后台、SEO 插件、主题模板或代码里找来源。
产品页、分类页、FAQ 页、案例页这类公开页面,一般不应该被误设为 noindex。
第三步:查 HTTP Header 里的 X-Robots-Tag
有些 noindex 不在 HTML 里,而在响应头里:
curl -sS -I -L "$PAGE" | \
grep -Ei '^(HTTP/|x-robots-tag:|content-type:|location:)'
如果你查 PDF、图片、下载文件,也要看这个头:
FILE="https://www.example.com/downloads/catalog.pdf"
curl -sS -I -L "$FILE" | \
grep -Ei '^(HTTP/|x-robots-tag:|content-type:|location:)'
X-Robots-Tag 可能来自服务器配置、CDN、SEO 插件或自定义代码。
不要只在 WordPress 页面编辑器里找。
第四步:查 WordPress 阅读设置
WordPress 后台有一个容易被忘记的开关:
Settings > Reading > Search engine visibility
检查:
- Discourage search engines from indexing this site 是否被勾选
- 测试站迁移到正式站后,这个选项是否仍然开启
- 取消勾选后,重新检查页面 meta robots 与响应头
如果正式外贸站上线后产品页长期不进索引,这个选项是第一批要查的地方。
WordPress.org 文档说明,勾选这个选项是请求搜索引擎不要索引站点;在较新的 WordPress 版本中,它会通过 wp_head 输出 robots meta。这里仍要加限定:如果主题没有正确调用 wp_head,或者服务器 / CDN 另行注入响应头,最终线上输出仍要用 curl 检查。
Site Health 也可以作为辅助入口。WordPress 的 Site Health 信息里会显示站点是否正在阻止搜索引擎索引。它适合提醒你“全站层面可能有问题”,但不能替代 URL 级别抽样检查。
第五步:查 SEO 插件和主题代码来源
常见来源可以按这个顺序排:
| 来源 | 检查内容 |
|---|---|
| WordPress 阅读设置 | 是否阻止搜索引擎索引本站点 |
| SEO 插件全局设置 | 文章、页面、产品、分类、标签是否被全局 noindex |
| 单篇页面设置 | 某个产品页是否单独设置 noindex |
| WooCommerce 产品归档 | 产品分类、标签、属性页是否被误设 |
| 主题模板 | 是否硬编码 robots meta |
| 自定义代码 | 是否通过 wp_robots、wp_robots_noindex() 或相关 filter 输出 noindex |
robots_txt filter |
是否动态改写线上 robots.txt |
| 服务器 / CDN | 是否注入 X-Robots-Tag |
WordPress 开发文档里有 wp_robots_noindex() 和 wp_robots 相关机制。
如果你们有开发同事,可以让他搜索主题和插件里的这些关键词:
grep -RIn \
'wp_robots\\|robots_txt\\|noindex\\|X-Robots-Tag' \
wp-content/themes wp-content/plugins
这条命令只适合在有权限的服务器或本地代码副本里跑。不要在生产环境乱改文件。
第六步:判断是不是 Disallow + noindex 打架
最常见的冲突是:
robots.txt:
User-agent: *
Disallow: /thank-you/
页面里又写:
<meta name="robots" content="noindex, follow">
如果搜索引擎被 robots.txt 拦住,它可能抓不到页面,也就看不到页面里的 noindex。
所以想让一个页面退出索引,通常要让 crawler 能访问到 noindex 指令。等状态稳定后,再按资源消耗或隐私需求决定是否限制抓取。
但敏感资料是另一回事。
报价单、客户资料、上传图纸、后台页面,不应该靠 robots.txt 或 noindex 保护,而应该用登录鉴权、权限控制和服务器访问限制。
第七步:做一个抽样检查表
| URL | 页面类型 | robots.txt 是否挡住 | meta robots | X-Robots-Tag | 判断 | 动作 |
|---|---|---|---|---|---|---|
/products/industrial-valve/ |
产品页 | 否 | 无 noindex |
无 | 正常 | 保持 |
/product-category/valves/ |
分类页 | 是 | 无 | 无 | 被误挡 | 修改 robots |
/request-a-quote/thank-you/ |
thank-you | 否 | noindex |
无 | 正常去索引 | 保持 |
/downloads/private-quote.pdf |
私密文件 | 未知 | 无 | noindex |
仍不够安全 | 加权限保护 |
这张表比“插件里看起来没问题”更可靠,因为它看的是线上实际输出。
第八步:修复后怎么复查
修复后不要只刷新后台。重新跑一遍:
curl -sS "$SITE/robots.txt" | \
sed -n '1,200p'
curl -sS -L "$PAGE" | \
grep -Ein \
'<meta[^>]+name=["'"'"']robots["'"'"']|noindex|nofollow|canonical'
curl -sS -I -L "$PAGE" | \
grep -Ei '^(HTTP/|x-robots-tag:|content-type:|location:)'
如果修的是 Google 索引问题,再去 Search Console 用 URL Inspection 看当前状态,并请求重新抓取。
这不是保证恢复排名,只是让 Google 更快重新处理最新状态。
常见误判
| 误判 | 为什么错 | 更稳妥做法 |
|---|---|---|
robots.txt 可以禁止收录 |
它主要控制抓取,不是可靠去索引工具 | 用 noindex,并让 crawler 能看到 |
noindex 写进 robots.txt 就行 |
Google 不支持这种做法 | 写 meta robots 或 X-Robots-Tag |
| SEO 插件没报错就没问题 | 线上可能被主题、服务器、CDN 改写 | 用 curl 查实际输出 |
| 后台资料加 noindex 就安全 | noindex 不是权限控制 | 用登录鉴权和服务器权限 |
| 所有低价值页面都 Disallow | crawler 可能看不到 noindex | 分清抓取控制和索引控制 |
| 修复后一定恢复 AI 引用 | 没有这种保证 | 只能说恢复可抓取 / 可索引基础 |
WordPress 外贸站做 AI SEO,先别急着加新页面。先确认核心产品页、分类页、FAQ、案例、About、RFQ 说明页没有被 noindex 或 robots 误伤。技术入口打通了,后面的内容优化才有意义。
参考资料
- Google: Introduction to robots.txt
- Google: Block Search indexing with noindex
- Google: Robots meta tag and X-Robots-Tag specifications
- Google: Ask Google to recrawl your URLs
- WordPress Documentation: Reading Settings
- WordPress Documentation: Site Health Screen
- WordPress Developer Resources: wp_robots_noindex()
- WordPress Developer Resources: wp_robots
- WordPress Developer Resources: robots_txt filter