website/content/zh-cn/docs/doc-contributor-tools/linkchecker
Qiming Teng c52818c03d Switch language name 'zh' to 'zh-cn'
This is the first step to rename 'zh' to 'zh-cn'. There are several reasons why we rename the language name.

- The upstream docsy theme changed the language name, leading to many warnings during site build;
  The side-effect is that the i18n strings are no longer working.
- We believe renaming the language is the right thing to do, because this move can make room for other variants of Chinese language, such as 'zh-tw', 'zh-sg' etc.

There would be several follow-ups to this PR, such as fixing the intra-site links, adding redirects etc.

We will lock up changes to zh/zh-cn pages for the moment, until this one gets in.

This PR is based on commit cdad0a7342.
2022-06-10 22:33:41 +08:00
..
README.md Switch language name 'zh' to 'zh-cn' 2022-06-10 22:33:41 +08:00

README.md

内置链接检查工具

你可以使用 htmltest 来检查 /content/en/ 下面的失效链接。 这在重构章节内容、移动页面或者重命名文件或页眉时非常有用。

工作原理

htmltest 会扫描 kubernetes website 仓库构建生成的 HTML 文件。通过执行 make 命令进行了下列操作:

  • 构建站点并输出 HTML 到本地 kubernetes/website 仓库下的 /public 目录中
  • 拉取 Docker 镜像 wdjp/htmltest
  • 挂载本地 kubernetes/website 仓库到 Docker 容器中
  • 扫描 /public 目录下生成的文件并将遇到的失效链接通过命令行打印出来

哪些链接不会检查

该链接检查器扫描生成的 HTML 文件,而非原始的 Markdown. 该 htmltest 工具依赖于配置文件 .htmltest.yml,来决定检查哪些内容。

该链接检查器扫描以下内容:

该链接检查器不会扫描以下内容:

  • 包含在顶部和侧边导航栏的链接,以及页脚链接或者页面的 <head> 部分中的链接,例如 CSS 样式表、脚本以及元信息的链接。
  • 顶级页面及其子页面,例如:/training/community/case-studies/adidas
  • 博客文章
  • API 参考文档,例如: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.18/
  • 本地化内容

先决条件以及安装说明

必须安装:

运行链接检查器

运行链接检查器需要:

  1. 进入本地 kubernetes/website 仓库的根目录下。

  2. 执行如下命令:

make container-internal-linkcheck

理解输出的内容

如果链接检查器发现了失效链接,则输出内容类似如下:

tasks/access-kubernetes-api/custom-resources/index.html
  hash does not exist --- tasks/access-kubernetes-api/custom-resources/index.html --> #preserving-unknown-fields
  hash does not exist --- tasks/access-kubernetes-api/custom-resources/index.html --> #preserving-unknown-fields

这是一系列失效链接。该日志附带了每个页面下的失效链接。

在这部分输出中,包含失效链接的文件是 tasks/access-kubernetes-api/custom-resources.md

该工具给出了一个理由:hash does not exist,在大部分情况下,你可以忽略这个。

目标链接是 #preserving-unknown-fields

修复这个问题的一种方式是:

  1. 转到含有失效链接的 Markdown 文件。
  2. 使用文本编辑器全文搜索失效链接的 URL通常使用 Ctrl+F 或 Command+F#preserving-unknown-fields.
  3. 修复该链接。对于一个失效的锚点(或者 anchor )链接,检查该主题是否已更名或者移除。

运行 htmltest 来验证失效链接是否已修复。