【问题标题】:JekyllRB: how to create an online book (force permalink to be like chapter/1)JekyllRB:如何创建在线书籍(强制永久链接类似于章节/1)
【发布时间】:2017-01-12 02:00:53
【问题描述】:

Jekyll 默认使用指定的变量来生成永久链接。但在我的情况下,我需要永久链接来使用页面特定变量(如 chapter)来生成类似 /chapters/:chapter 的 URL,而不是使用日期和其他内容

【问题讨论】:

  • 使用集合?

标签: ruby jekyll jekyll-extensions


【解决方案1】:

您不能使用任何前端变量来创建永久链接,只能使用the Jekyll defined keys for the type of page

如 Wickramaranga 所说,要获取您所追求的 URL,您可以使用集合。在你的 _config.yml 中,你定义你的章节集合:

collections:
  chapters:
    output: true
    permalink: /chapters/:title/

然后创建您的章节,例如/_chapters/1.md, /_chapters/2.md.

这将创建 http://localhost:4000/chapters/1/http://localhost:4000/chapters/2/

【讨论】:

    猜你喜欢
    • 2011-05-02
    • 1970-01-01
    • 1970-01-01
    • 2015-09-06
    • 2017-12-20
    • 1970-01-01
    • 2021-04-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多