jekyll 中使用永久链接

Jekyll 支持以灵活的方式管理你网站的链接,你可以通过 Configuration或 YAML 头信息 为每篇文章设置永久链接。你可以随心所欲地选择内建链接格式,或者自定义链接格式。默认配置为 date

永久链接的模板用以冒号为前缀的关键词标记动态内容,比如 date 代表 /:categories/:year/:month/:day/:title.html

模板变量

变量 描述

year

文章所在文件的年份

month

文章所在文件的月份,格式如 `01, 10`

i_month

文章所在文件的月份,格式如 `1, 10`

day

文章所在文件的日期,格式如 `01, 20`

i_day

文章所在文件的日期,格式如 `1, 20`

title

文章所在文件的标题

categories

为文章配置的目录,Jekyll 可以自动将 `//` 转换为 `/` ,所以如果没有目录,会自动忽略

已经建好的链接类型

链接类型 URL 模板

date

/:categories/:year/:month/:day/:title.html

pretty

/:categories/:year/:month/:day/:title/

none

/:categories/:title.html

举例

比如文件名: /2009-04-29-slap-chop.textile

设置 对应的 URL

没有配置或 permalink: date

/2009/04/29/slap-chop.html

permalink: pretty

/2009/04/29/slap-chop/index.html

permalink: /:month-:day-:year/:title.html

/04-29-2009/slap-chop.html

permalink: /blog/:year/:month/:day/:title

/blog/2009/04/29/slap-chop/index.html

猜你喜欢

转载自sunxboy.iteye.com/blog/2171768