Nimbus 自动处理元数据基线,并在需要时提供逐页和站点级别的控制。
标题和描述
title 和 description frontmatter 会填充 <title> 和 <meta name="description">,并用于搜索摘要和 llms.txt 索引。站点级别的回退值来自 Nimbus 配置:
nimbus({
site: "https://docs.example.com",
title: "Acme",
description: "Build with Acme.",
});Open Graph 图片
设置站点级别的回退卡片和替代文本,然后逐页覆盖:
nimbus({
/* … */
socialImage: "/og.png",
socialImageAlt: "Acme documentation",
});---
title: Pricing
socialImage: /og/pricing.png
---Nimbus 还提供了 OG 图片路由,因此没有显式图片的页面会获得生成的卡片。
图片路径是不包含 Astro 部署基础路径的逻辑路径。对于部署在 /docs 的站点,保持 socialImage: "/og.png";Nimbus 会生成 /docs/og.png。绝对路径和协议相对的图片 URL 会被保留。
站点地图和 robots
设置 site 后,站点地图集成和 /robots.txt 会自动配置。可通过在集成选项中设置 sitemap: false 来禁用站点地图。
逐页和站点级别头部
通过 config.head 在站点级别向 <head> 添加元素,或通过 frontmatter 逐页添加 — 两者会合并:
---
title: Analytics-tracked page
head:
- tag: meta
attrs: { name: "robots", content: "noindex" }
- tag: link
attrs: { rel: "canonical", href: "https://example.com/canonical" }
---有效的标签:meta、link、script、style、title、noscript、base。要在不手动编写标签的情况下将页面排除在爬虫之外,请使用 noindex: true。
规范 URL
在版本化站点上,Nimbus 会生成 <link rel="canonical">,将旧版本指向当前版本,以及兄弟版本之间的 <link rel="alternate"> — 由 previousSlug 驱动。