JekyllRB:如何创建在线书籍(强制永久链接像 chapter/1)
JekyllRB: how to create an online book (force permalink to be like chapter/1)
Jekyll 默认使用指定的变量来生成永久链接。但在我的例子中,我需要永久链接来使用页面特定变量,如 chapter
来生成 url 类似 /chapters/:chapter
的东西,而不是使用日期和其他东西
您不能使用任何前端变量来创建永久链接,只能使用 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/ and http://localhost:4000/chapters/2/
Jekyll 默认使用指定的变量来生成永久链接。但在我的例子中,我需要永久链接来使用页面特定变量,如 chapter
来生成 url 类似 /chapters/:chapter
的东西,而不是使用日期和其他东西
您不能使用任何前端变量来创建永久链接,只能使用 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/ and http://localhost:4000/chapters/2/