如何在 Jekyll 中的站点根目录中引用“_pages”?

问题描述 投票:0回答:2

我在 GitHub Pages 上托管了 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/

yaml jekyll
2个回答
5
投票

_pages
可以看作是
collection
目录。 因此,只需进行以下配置即可:

collections:
  pages:
    output: true

会给你类似

https://repo.github.io/pages/some-page.html

的网址

要获取自定义 URL,您可以添加

permalink
子配置:

collections:
  pages:
    output: true
    permalink: /:collection/:path/

会给你类似

https://repo.github.io/pages/some-page/

的网址

更多可能性,请参阅官方文档


0
投票

例如。 https://repo.github.io/some-page,您可以输入

_pages
并进行如下配置:

collections:
  pages:
    output: true
    permalink: /:name
© www.soinside.com 2019 - 2024. All rights reserved.