rspress-description-generator
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseRspress Description Generator
Rspress 描述生成器
The field in Rspress frontmatter generates tags, which are used for search engine snippets, social media previews, and AI-oriented formats like llms.txt.
description<meta name="description" content="...">Rspress frontmatter中的字段会生成标签,用于搜索引擎摘要、社交媒体预览以及llms.txt这类面向AI的格式。
description<meta name="description" content="...">Step 1 — Locate the docs root
步骤1 — 定位文档根目录
- Find the Rspress config file. Search for ,
rspress.config.ts,.js, or.mjs. It may be at the project root or inside a subdirectory like.cjs.website/ - Read the config and extract the option.
root- The value might be a plain string () or a JS expression (
root: 'docs'). In either case, determine the resolved directory path.root: path.join(__dirname, 'docs') - If is set, resolve it relative to the config file's directory.
root - If is not set, default to
rootrelative to the config file's directory.docs
- The value might be a plain string (
- Confirm the directory exists. If neither nor the configured root exists, check for
docsas a fallback.doc
- 找到Rspress配置文件。搜索、
rspress.config.ts、.js或.mjs文件,它可能位于项目根目录或.cjs之类的子目录中。website/ - 读取配置并提取选项。
root- 该值可能是普通字符串()或JS表达式(
root: 'docs')。无论哪种情况,都要确定解析后的目录路径。root: path.join(__dirname, 'docs') - 如果设置了,则相对于配置文件所在目录解析它。
root - 如果未设置,默认使用配置文件所在目录下的
root目录。docs
- 该值可能是普通字符串(
- 确认目录存在。如果目录和配置的root目录都不存在,检查
docs目录作为备选。doc
Step 2 — Detect i18n structure
步骤2 — 检测国际化(i18n)结构
Rspress i18n projects place language subdirectories (e.g., , ) directly under the docs root:
en/zh/docs/
├── en/
│ ├── guide/
│ └── index.md
└── zh/
├── guide/
└── index.mdCheck if the docs root contains language subdirectories (two-letter codes like , , , , etc.). If so, process each language directory separately — the description language should match the content language.
enzhjakoIf there are no language subdirectories, treat the entire docs root as a single-language site.
Rspress国际化项目会将语言子目录(如、)直接放在文档根目录下:
en/zh/docs/
├── en/
│ ├── guide/
│ └── index.md
└── zh/
├── guide/
└── index.md检查文档根目录是否包含语言子目录(如、、、等双字母代码)。如果存在,则单独处理每个语言目录——描述语言应与内容语言匹配。
enzhjako如果没有语言子目录,则将整个文档根目录视为单语言站点。
Step 3 — Scan and process files
步骤3 — 扫描并处理文件
Glob for and under the docs root. Exclude:
**/*.md**/*.mdx- , build output (
node_modules,doc_build,.rspress)dist - /
_meta.json(sidebar/nav config files, not doc pages)_nav.json - directories (reusable snippets included via
**/shared/**, not standalone pages)@import
For each file:
- Read the file.
- Check for existing in frontmatter. If it exists and is non-empty, skip.
description - Check in frontmatter. For
pageTypepages, derive the description from thehome/hero.textfields or the features list, not from body content.hero.tagline - Generate a description following the writing guidelines below.
- Insert into frontmatter:
description-
If the file has frontmatter with afield, insert
titleon the line afterdescription.title -
If the file has frontmatter without, insert
titleas the first field.description -
If the file has no frontmatter block, add one:yaml
--- description: Your generated description here ---
-
在文档根目录下匹配和文件,排除以下内容:
**/*.md**/*.mdx- 、构建输出目录(
node_modules、doc_build、.rspress)dist - /
_meta.json(侧边栏/导航配置文件,非文档页面)_nav.json - 目录(通过
**/shared/**引入的可复用代码片段,非独立页面)@import
对于每个文件:
- 读取文件内容。
- 检查frontmatter中是否已有。如果存在且非空,则跳过。
description - 检查frontmatter中的。对于
pageType类型页面,从home/hero.text字段或功能列表推导描述,而非从正文内容生成。hero.tagline - 按照以下写作指南生成描述。
- 将插入frontmatter:
description-
如果文件的frontmatter包含字段,在
title字段的下一行插入title。description -
如果文件的frontmatter没有字段,将
title作为第一个字段插入。description -
如果文件没有frontmatter块,则添加一个:yaml
--- description: 生成的描述内容 ---
-
YAML formatting
YAML格式规范
Most descriptions can be bare YAML strings:
yaml
description: Step-by-step guide to setting up your first Rspress siteIf the description contains colons, quotes, or other special YAML characters, wrap in double quotes:
yaml
description: 'API reference for Rspress configuration: plugins, themes, and build options'大多数描述可以直接使用YAML字符串:
yaml
description: 搭建首个Rspress站点的分步指南如果描述包含冒号、引号或其他特殊YAML字符,需用双引号包裹:
yaml
description: 'Rspress配置API参考:插件、主题和构建选项'Step 4 — Batch processing
步骤4 — 批量处理
For sites with many files, use parallel agent calls to process independent files simultaneously. Group by directory (e.g., all files in , then all in ) to maintain focus and consistency within each section.
guide/api/After processing all files, do a quick scan to ensure no files were missed — re-glob and check for any remaining files without .
description对于包含大量文件的站点,使用并行代理调用同时处理独立文件。按目录分组(如先处理下的所有文件,再处理下的所有文件),以保持每个章节的聚焦性和一致性。
guide/api/处理完所有文件后,快速扫描确保没有遗漏——重新匹配文件并检查是否还有未添加的文件。
descriptionDescription Writing Guidelines
描述写作指南
The description serves three audiences: search engines (Google snippet), AI systems (llms.txt, summarization), and humans (scanning search results). A good description helps all three.
描述服务于三类受众:搜索引擎(谷歌摘要)、AI系统(llms.txt、摘要生成)和人类(浏览搜索结果)。优质的描述需同时满足三者需求。
Rules
规则
- Length: 50–160 characters. Under 50 is too vague for search engines; over 160 gets truncated in snippets.
- Language: Match the document content. Chinese docs get Chinese descriptions, English docs get English descriptions.
- Be direct: State what the page covers. Avoid starting with "This document", "This page", "Learn about" — jump straight to the substance.
- Be specific: Mention concrete technologies, APIs, or concepts the page covers. "Configure Rspress plugins for search, analytics, and internationalization" beats "How to use plugins."
- No markdown: Plain text only, no formatting syntax.
- 长度:50–160字符。少于50字符对搜索引擎来说过于模糊;超过160字符会在摘要中被截断。
- 语言:与文档内容语言匹配。中文文档使用中文描述,英文文档使用英文描述。
- 直接明了:说明页面涵盖的内容。避免以“本文档”“本页面”“了解”开头——直接切入核心内容。
- 具体明确:提及页面涵盖的具体技术、API或概念。“为搜索、分析和国际化配置Rspress插件”比“如何使用插件”更优。
- 无Markdown:仅使用纯文本,不包含格式语法。
Examples
示例
Good:
| Content | Description |
|---|---|
| Plugin development guide | Create custom Rspress plugins using the Node.js plugin API and runtime hooks |
| MDX component usage | Import and use React components in MDX documentation files |
| Rspress 快速开始 | 从安装到本地预览,搭建 Rspress 文档站点的完整流程 |
| 主题配置 | 自定义 Rspress 主题的导航栏、侧边栏、页脚和暗色模式 |
| Home page (pageType: home) | Rspress documentation framework — fast, MDX-powered static site generator |
Bad:
| Description | Why |
|---|---|
| "About plugins" | Too vague — which plugins? what about them? |
| "This page explains how to configure the Rspress theme" | Wastes characters on "This page explains how to" |
| "Learn everything about Rspress!" | Marketing fluff, says nothing specific |
优秀示例:
| 内容 | 描述 |
|---|---|
| 插件开发指南 | 使用Node.js插件API和运行时钩子创建自定义Rspress插件 |
| MDX组件使用 | 在MDX文档文件中导入并使用React组件 |
| Rspress 快速开始 | 从安装到本地预览,搭建 Rspress 文档站点的完整流程 |
| 主题配置 | 自定义 Rspress 主题的导航栏、侧边栏、页脚和暗色模式 |
| 首页(pageType: home) | Rspress文档框架——快速、基于MDX的静态站点生成器 |
反面示例:
| 描述 | 原因 |
|---|---|
| "关于插件" | 过于模糊——哪些插件?涉及哪些内容? |
| "本页面讲解如何配置Rspress主题" | 浪费字符在“本页面讲解如何”上 |
| "了解关于Rspress的一切!" | 营销话术,未说明具体内容 |
Documentation
参考文档
- Frontmatter fields: https://rspress.rs/api/config/config-frontmatter
- Basic config (option): https://rspress.rs/api/config/config-basic
root - Full Rspress docs: https://rspress.rs/llms.txt
- Frontmatter字段:https://rspress.rs/api/config/config-frontmatter
- 基础配置(选项):https://rspress.rs/api/config/config-basic
root - Rspress完整文档:https://rspress.rs/llms.txt