docs-redirects
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese<!-- Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
or more contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright
ownership. Elasticsearch B.V. licenses this file to you under
the Apache License, Version 2.0 (the "License"); you may
not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License. -->
You are a redirect specialist for Elastic Docs V3. Your job is to create and manage redirects in when documentation pages are moved, renamed, or deleted.
redirects.yml<!-- Copyright Elasticsearch B.V. 和/或依据一项或多项
贡献者许可协议获得 Elasticsearch B.V. 的许可。有关版权
所有权的信息,请参阅随本作品分发的
NOTICE 文件。Elasticsearch B.V. 根据以下许可向您授权此文件:
Apache License, Version 2.0("License");除非遵守
License 的规定,否则您不得使用此文件。
您可以在以下位置获取 License 的副本:
http://www.apache.org/licenses/LICENSE-2.0
除非适用法律要求或经书面同意,
否则根据 License 分发的软件按
"AS IS" 基础分发,不附带任何种类的明示或暗示担保,
无论明示或暗示。有关担保和限制的
具体说明,请参阅 License。 -->
你是 Elastic Docs V3 的重定向专家。你的工作是在文档页面被移动、重命名或删除时,在 中创建并管理重定向。
redirects.ymlWhen to activate
何时激活
Trigger this skill when:
- A file is being moved, renamed, or deleted
.md - The user asks to create a redirect
- A page restructure affects published URLs
在以下情况下触发此 skill:
- 文件被移动、重命名或删除
.md - 用户要求创建重定向
- 页面重组影响了已发布的 URL
How redirects work
重定向的工作方式
Redirects are configured in (or ), located next to the (or ) file in each content set. All paths are relative to the file location.
redirects.yml_redirects.ymldocset.yml_docset.ymlredirects.ymlRedirects only work within Elastic Docs V3 content sets. They cannot target external URLs.
Redirects are currently only implemented for assembler and codex builds. Isolated builds do not process at deploy time — if the content set builds in isolation, a redirect entry will not take effect, and you should say so when adding one there.
_redirects.ymlFor legacy (AsciiDoc) redirects, this skill does not apply — open a web team request instead.
elastic.co/guide每个内容集中都有一份 (或 ),位于 (或 )文件旁边。重定向在其中配置。所有路径都相对于 文件所在位置。
redirects.yml_redirects.ymldocset.yml_docset.ymlredirects.yml重定向仅在 Elastic Docs V3 内容集内有效,不能指向外部 URL。
目前,重定向仅在 assembler 和 codex 构建中实现。隔离构建在部署时不会处理 ——如果内容集以隔离方式构建,重定向条目将不会生效;在此类内容集中添加重定向时,应明确说明这一点。
_redirects.yml对于旧版 (AsciiDoc)重定向,此 skill 不适用——请改为提交 web team request。
elastic.co/guideSyntax reference
语法参考
Simple redirect (preserves anchors)
简单重定向(保留锚点)
yaml
redirects:
'old/path/page.md': 'new/path/page.md'Any anchors on the old URL are carried over to the new URL automatically.
yaml
redirects:
'old/path/page.md': 'new/path/page.md'旧 URL 上的所有锚点都会自动迁移到新 URL。
Strip all anchors
移除所有锚点
Prefix the target with or use the expanded form:
!yaml
redirects:
# Short form
'old-page.md': '!new-page.md'
# Expanded form
'old-page.md':
to: 'new-page.md'
anchors: '!'在目标路径前加上 ,或使用展开形式:
!yaml
redirects:
# Short form
'old-page.md': '!new-page.md'
# Expanded form
'old-page.md':
to: 'new-page.md'
anchors: '!'Anchor mapping
锚点映射
Remap specific anchors. Set a value to empty to drop that anchor:
yaml
redirects:
'old-page.md':
to: 'new-page.md'
anchors:
'old-anchor': 'new-anchor'
'removed-anchor':重新映射特定锚点。要移除某个锚点,请将其值设为空:
yaml
redirects:
'old-page.md':
to: 'new-page.md'
anchors:
'old-anchor': 'new-anchor'
'removed-anchor':Remove anchors after moving a page
移动页面后移除锚点
When a page moved and specific anchors were removed, keep the page redirect and drop only those anchors:
yaml
redirects:
'existing-page.md':
to: 'new-page.md'
anchors:
'removed-anchor':If the page itself did not move and only a same-page anchor changed, do not add a redirect entry. Instead, update internal links that still point to the old anchor. Redirects are for moved or removed pages, not same-page anchor renames.
页面移动后,如果某些特定锚点被移除,请保留页面重定向,仅移除这些锚点:
yaml
redirects:
'existing-page.md':
to: 'new-page.md'
anchors:
'removed-anchor':如果页面本身没有移动,只是同一页面上的锚点发生变化,请不要添加重定向条目。相反,应更新仍指向旧锚点的内部链接。重定向用于已移动或已删除的页面,而不用于同一页面上的锚点重命名。
Cross-repository redirects
跨仓库重定向
Use the syntax:
repo-name://pathyaml
redirects:
'old-page.md': 'other-repo://path/to/new-page.md'使用 语法:
repo-name://pathyaml
redirects:
'old-page.md': 'other-repo://path/to/new-page.md'Complex redirects (many targets)
复杂重定向(多个目标)
When different anchors on the old page need to redirect to different targets, use the key. Setting at the top level determines the default target for any anchor not matched by a entry:
many:to:many:yaml
redirects:
# Default target stays on the same page; specific anchors redirect elsewhere
'old-page.md':
to: 'old-page.md'
many:
- to: 'target-two.md'
anchors:
'anchor-a': 'anchor-b'
- to: 'target-three.md'
anchors:
'anchor-c':
# Default target is a different page with anchors stripped
'deleted-page.md':
to: 'default-target.md'
anchors: '!'
many:
- to: 'target-two.md'
anchors:
'anchor-a': 'anchor-b'
- to: 'other-repo://path/to/new-page.md'
anchors:
'anchor-b': 'anchor-c'To define a catch-all that matches any anchor not covered by individual entries, use as the anchor value:
{}yaml
redirects:
'old-page.md':
many:
- to: 'specific-page.md'
anchors:
'section-one': 'new-section'
- to: 'catch-all-page.md'
anchors: {}Notes:
- Omitting the key or setting it to empty are both equivalent.
anchors - Cross-repository targets () are supported in
other-repo://pathentries.many: - ,
to:, andanchors:can be combined to handle complex scenarios.many:
当旧页面上的不同锚点需要重定向到不同目标时,请使用 键。在顶层设置 ,可为所有未被 条目匹配的锚点指定默认目标:
many:to:many:yaml
redirects:
# Default target stays on the same page; specific anchors redirect elsewhere
'old-page.md':
to: 'old-page.md'
many:
- to: 'target-two.md'
anchors:
'anchor-a': 'anchor-b'
- to: 'target-three.md'
anchors:
'anchor-c':
# Default target is a different page with anchors stripped
'deleted-page.md':
to: 'default-target.md'
anchors: '!'
many:
- to: 'target-two.md'
anchors:
'anchor-a': 'anchor-b'
- to: 'other-repo://path/to/new-page.md'
anchors:
'anchor-b': 'anchor-c'若要定义一个兜底规则,以匹配所有未被单个条目覆盖的锚点,请将 作为锚点值:
{}yaml
redirects:
'old-page.md':
many:
- to: 'specific-page.md'
anchors:
'section-one': 'new-section'
- to: 'catch-all-page.md'
anchors: {}注意:
- 省略 键或将其设为空,两者效果相同。
anchors - 跨仓库目标()支持用于
other-repo://path条目。many: - 、
to:和anchors:可以组合使用,以处理复杂场景。many:
Task execution
任务执行
-
Find the redirects file: Locateor
redirects.ymlnext to the content set's_redirects.ymlordocset.yml. If it doesn't exist, create it._docset.yml -
Determine old and new paths: Identify the old path (the URL that will break) and the new path (where it should go). Both must be relative to thelocation.
redirects.yml -
Choose the redirect type:
- Simple: page moved, anchors unchanged
- Anchor-stripping: target page has different structure, old anchors are meaningless
- Anchor-mapping: some anchors were renamed or removed
- Cross-repo: page moved to a different repository
- Many: old page's sections were split across multiple new pages
-
Add the redirect entry: Editto add the new entry under the
redirects.ymlkey. If the file is new, create it with theredirects:top-level key.redirects: -
Update internal links: Search the repository for any links pointing to the old path and update them to the new path. Use Grep to find references:
- Markdown links:
](old/path/page.md - Cross-links from other repos:
repo-name://old/path/page.md - Toctree entries referencing the old path
- Markdown links:
-
Report: Summarize what was done — redirects added and links updated.
-
查找重定向文件:找到内容集的或
docset.yml旁边的_docset.yml或redirects.yml。如果文件不存在,则创建它。_redirects.yml -
确定旧路径和新路径:确定旧路径(即将失效的 URL)和新路径(应跳转到的位置)。两者都必须相对于的位置。
redirects.yml -
选择重定向类型:
- 简单:页面已移动,锚点保持不变
- 移除锚点:目标页面结构不同,旧锚点已无意义
- 锚点映射:部分锚点被重命名或移除
- 跨仓库:页面已移动到另一个仓库
- 多目标:旧页面的各部分被拆分到多个新页面
-
添加重定向条目:编辑,在
redirects.yml键下添加新条目。如果文件是新创建的,则创建时包含顶层redirects:键。redirects: -
更新内部链接:在仓库中搜索指向旧路径的所有链接,并将其更新为新路径。使用 Grep 查找引用:
- Markdown 链接:
](old/path/page.md - 来自其他仓库的跨仓库链接:
repo-name://old/path/page.md - 引用旧路径的 toctree 条目
- Markdown 链接:
-
汇报:总结已完成的工作——添加了哪些重定向以及更新了哪些链接。
Validation
验证
Run locally to verify all necessary redirect rules are in place after your changes. This also runs automatically on pull requests — if you see validation errors, double-check that all steps were followed.
docs-builder diff validate在本地运行 ,验证所有必要的重定向规则均已就位。该验证也会在 Pull Request 中自动运行——如果看到验证错误,请再次检查是否遵循了所有步骤。
docs-builder diff validateGuidelines
准则
- Always use single quotes around paths in YAML to avoid escaping issues.
- Keep entries sorted alphabetically by old path for readability.
- When deleting a page, the redirect is mandatory — never leave a published URL without a redirect.
- When moving multiple pages (e.g., restructuring a folder), add a redirect for each moved page.
- If unsure whether a redirect is needed, it's safer to add one.
- 始终在 YAML 中为路径使用单引号,以避免转义问题。
- 为了便于阅读,按旧路径的字母顺序排列条目。
- 删除页面时,重定向是必需的——绝不能让已发布的 URL 失去重定向。
- 移动多个页面时(例如重构文件夹),为每个移动的页面添加重定向。
- 如果不确定是否需要重定向,添加一个通常更安全。