Metadata
品牌配置、页面 SEO、canonical、Open Graph、robots、sitemap 与 JSON-LD。
Metadata 分成项目品牌、页面 head 和公开内容结构化数据三层。品牌意图来自 Manifest,页面路由声明自己的 title/description,公共 helper 负责 canonical、Open Graph、Twitter 和 noindex 一致性。
项目品牌
在 project.manifest.json 修改 brand、project.baseUrl 和默认 locale,然后运行:
pnpm init:template
pnpm check:template生成的公共配置供 Web 根文档、Header/Footer、canonical、Feed 和 JSON-LD 共用。不要在页面组件里复制站点 origin 或品牌名。
页面策略
- 公开页面使用
buildPublicSeo,提供稳定 path、title、description、site name 和 site URL。 - 登录、搜索、上传、Favorites、Rewrite 等私有/工具页面使用 noindex/nofollow。
- Project detail 在授权失败时不把受限对象 metadata 泄漏进 HTML。
- Blog/Changelog/Legal 从经过构建期校验的 frontmatter 生成 metadata。
路由级 metadata 放在 TanStack file route 的 head 中。绝对 URL 统一通过 apps/web/src/lib/urls.ts 生成。
Robots、Sitemap 与 JSON-LD
apps/web/src/lib/seo.ts 维护固定 noindex 路径、robots 和 Site Content JSON-LD。根文档输出 WebSite;公开内容按类型输出 BlogPosting、TechArticle 或 WebPage。
结构化数据必须经 @tanplate/ui 的安全序列化 helper 输出。新增公开路由时同步检查 Vite sitemap;新增私有路由时更新 noindex/robots 策略和测试。