【问题标题】:How to get "_pages" referenced at the site root in Jekyll?如何在 Jekyll 的站点根目录中获取“_pages”引用?
【发布时间】:2018-03-27 10:43:55
【问题描述】:

我在 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


    【解决方案1】:

    _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/这样的网址

    更多可能性,请参考official docs

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-02-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多