DEPLOY.md 4.2 KB

GEO 资产部署与验收

本文只说明 retrieval 子项目的 GEO 资产。项目使用 pnpm,Vite 构建目录为 price/price/ 已被 Git 忽略,不要直接手工修改其中的文件。

资产分层

构建后需要随站点上传:

  • public/llms.txt/llms.txt
  • public/robots.txt/robots.txt
  • public/sitemap.xml/sitemap.xml
  • index.html 中的 Organization、WebSite 和 SoftwareApplication JSON-LD
  • 首页渲染的产品定义、FAQ、WebPage 和 FAQPage JSON-LD

只在仓库内维护,不要单独上传:

  • geo/jsonld/:结构化数据的可审阅源文件
  • geo/snippets/:产品定义和 FAQ 的无样式 HTML 内容稿
  • geo/internal/:事实边界、来源和禁写项
  • geo/outlines/:内容团队的大纲

geo/jsonld/article.jsongeo/jsonld/breadcrumb.json 是候选模板,不应直接加入当前首页:

  • 当前首页是产品页,应使用 WebPage,而不是把首页标记成 Article。只有发布真实的独立文章页,并补充准确的发布日期、修改日期和可抓取图片后,才可部署 Article。
  • 面包屑模板描述 /contact 的“首页 → 获取方案”层级。只有页面增加可见面包屑并配置该路由的独立页面元数据后,才可部署。

单独上传 JSON 文件不会让搜索引擎自动识别结构化数据;需要使用的 JSON-LD 必须出现在对应页面的 <script type="application/ld+json"> 中。

构建

pnpm lint
pnpm build

构建完成后确认以下文件存在:

test -f price/llms.txt
test -f price/robots.txt
test -f price/sitemap.xml

上传完整的 price/ 目录,不要只上传 index.htmlassets/

Web 服务器配置

现网曾将不存在的 /llms.txt/robots.txt/sitemap.xml 回退成首页 HTML。部署时要让真实静态文件优先于 SPA fallback,并为文本和 XML 返回正确的内容类型。

以下 Nginx 片段仅展示路由原则;root、缓存策略和安全头应合并到实际站点配置中:

location = /llms.txt {
    try_files $uri =404;
    default_type text/plain;
    charset utf-8;
}

location = /robots.txt {
    try_files $uri =404;
    default_type text/plain;
}

location = /sitemap.xml {
    try_files $uri =404;
    default_type application/xml;
}

location /assets/ {
    try_files $uri =404;
}

location = / {
    try_files /index.html =404;
}

location ~ ^/(contact|privacy|agreement)/?$ {
    try_files /index.html =404;
}

location / {
    try_files $uri =404;
}

如果新增前端路由,需要同步更新允许回退到 index.html 的路由列表。未知路径应返回 404,避免形成 soft 404。

上线后验收

先检查状态码和内容类型:

curl -fsSI https://price.kailin.com.cn/llms.txt
curl -fsSI https://price.kailin.com.cn/robots.txt
curl -fsSI https://price.kailin.com.cn/sitemap.xml

预期:

  • /llms.txt 返回 200text/plain; charset=utf-8
  • /robots.txt 返回 200text/plain
  • /sitemap.xml 返回 200 和 XML 内容类型
  • 三个响应的正文都不是首页 HTML
  • 任意不存在的路径返回 404

再检查内容:

curl -fsS https://price.kailin.com.cn/llms.txt
curl -fsS https://price.kailin.com.cn/sitemap.xml

使用可执行 JavaScript 的浏览器检查首页:

  • 产品定义和 6 条 FAQ 可见,FAQ 可用键盘展开
  • 页面中存在 Organization、WebSite、WebPage、SoftwareApplication 和 FAQPage
  • FAQPage 的问题与答案和页面可见内容一致
  • 控制台没有新增错误

最后使用 Schema Markup Validator 校验 Schema.org 语法,并使用 Google Rich Results Test 与 Search Console URL Inspection 检查线上抓取结果。结构化数据有助于机器理解页面,但不保证获得富结果或生成式搜索引用。

当前限制

当前站点是客户端渲染的 React SPA,首次返回的 HTML 不包含完整页面正文。llms.txt 为不执行 JavaScript 的抓取器提供了核心事实,但若要进一步提高所有爬虫的可读性,后续仍应为首页和重要路由增加静态预渲染或服务端渲染,并为各路由提供独立的 title、description 和 canonical。