TECH

本站和 SEO 相关的几项工程——site、元信息、sitemap,以及和内容集合怎么对上。

Astro 的静态输出本来就对爬虫友好——构建时 HTML 就写死了,不用等 JS 跑完。剩下要做的是几件不复杂但容易漏的事。

site

astro.config 里的 site 要和线上 canonical 域名一致,RSS、sitemap、Astro.site 拼的绝对 URL 都依赖这一项。有预览部署的话,打生产包时确认别用了预览地址。

每页 meta

<title> 每页对应就行,不用塞关键词。description 我放 frontmatter 可选;空着时搜索引擎自己截一段正文,略失控,能写还是写。

canonical 一行,在 Layout 里:

<link rel="canonical" href={new URL(Astro.url.pathname, Astro.site)} />

OG 标签主要影响分享卡片,og:image 用 HTTPS 绝对地址,当前用全站默认图兜底。

Sitemap

RSS 已经有了(/rss.xml)。Sitemap 还没接,下一个候选是 @astrojs/sitemap——配好 site 构建时自动生成,robots.txt 指一下即可:

User-agent: *
Allow: /

Sitemap: https://www.qunqin.net/sitemap-index.xml

Content Collections 和 meta 对上

文章页从 entry.datatitledescription 注入 <head>。以后 frontmatter 加封面图字段,顺带喂 og:image

JSON-LD 先不急,canonical 和 title 做对了再说。