如何在 Jekyll 的站点根目录中引用“_pages”?
How to get "_pages" referenced at the site root in Jekyll?
我在 GitHub 页面上托管了 Jekyll 站点。文件 _config.yml
包含以下内容(摘录):
# Defaults
defaults:
# _pages
- scope:
path: "_pages"
type: "pages"
values:
layout: "single"
read_time: true
所以当网站建好后,我可以通过它的 URL 打开一个页面,像这样:
https://repo.github.io/_pages/some-page/
我阅读了 Jekyll 的所有文档,但我不清楚如何将此 URL 变为 https://repo.github.io/some-page/
或 https://repo.github.io/pages/some-page/
.
_pages
可以看作是collection
目录。
因此,只需具有以下配置:
collections:
pages:
output: true
会给你像 https://repo.github.io/pages/some-page.html
这样的 URL
要获取自定义网址,您可以添加 permalink
sub-config:
collections:
pages:
output: true
permalink: /:collection/:path/
会给你像 https://repo.github.io/pages/some-page/
这样的 URL
有关更多可能性,请参阅 official docs
我在 GitHub 页面上托管了 Jekyll 站点。文件 _config.yml
包含以下内容(摘录):
# Defaults
defaults:
# _pages
- scope:
path: "_pages"
type: "pages"
values:
layout: "single"
read_time: true
所以当网站建好后,我可以通过它的 URL 打开一个页面,像这样:
https://repo.github.io/_pages/some-page/
我阅读了 Jekyll 的所有文档,但我不清楚如何将此 URL 变为 https://repo.github.io/some-page/
或 https://repo.github.io/pages/some-page/
.
_pages
可以看作是collection
目录。
因此,只需具有以下配置:
collections:
pages:
output: true
会给你像 https://repo.github.io/pages/some-page.html
要获取自定义网址,您可以添加 permalink
sub-config:
collections:
pages:
output: true
permalink: /:collection/:path/
会给你像 https://repo.github.io/pages/some-page/
有关更多可能性,请参阅 official docs