为 GitHub Pages 站点创建自定义 404 页面
您可以自定义在人们尝试访问您站点上不存在的页面时显示的 404 错误页面。
GitHub Pages 可用于具有 GitHub Free 的公共仓库,以及具有 GitHub Pro、GitHub Team、GitHub Enterprise Cloud 和 GitHub Enterprise Server 的公共和私有仓库。
-
在 GitHub Enterprise 上,导航到站点的仓库。
-
导航到站点的发布来源。 有关发布源的更多信息,请参阅“关于 GitHub Pages”。
-
在文件列表上方,单击 Create new file(创建新文件)。

-
In the file name field, type
404.htmlor404.md.
-
If you named your file
404.md, add the following YAML front matter to the beginning of the file:--- permalink: /404.html --- -
Below the YAML front matter, if present, add the content you want to display on your 404 page.
-
在页面底部,输入一条简短、有意义的提交消息,描述您对文件所作的更改。 您可以在提交消息中将提交归于多个作者。 更多信息请参阅“创建有多个合作作者的提交”。

-
在提交消息字段下面,确定是要将提交添加到当前分支还是新分支。 如果当前分支是
master,则应选择为提交创建新分支,然后创建拉取请求。 更多信息请参阅“创建新的拉取请求”。
-
单击 Propose new file(提议新文件)。

延伸阅读
- Front matter in the Jekyll documentation