你可以在 _config.yml 中或每篇文章的头条中指定你网站的永久链接。
¥You can specify the permalinks for your site in _config.yml or in the front-matter for each post.
变量
¥Variables
除了以下变量外,你可以在永久链接中使用除 :path 和 :permalink 之外的任何属性。
¥Besides the following variables, you can use any attributes in the permalink except :path and :permalink.
| 变量 | 描述 |
|---|---|
:year |
帖子发布年份(4 位数字) |
:month |
帖子发布月份(2 位数字) |
:i_month |
帖子发布月份(不带前导零) |
:day |
帖子发布日期(2 位数字) |
:i_day |
帖子发布日期(不带前导零) |
:hour |
帖子发布小时(2 位数字) |
:minute |
帖子发布分钟(2 位数字) |
:second |
帖子发布秒(2 位数字) |
:title |
文件名(相对于 “source/_posts/“ 文件夹) |
:name |
文件名 |
:post_title |
帖子标题 |
:id |
帖子 ID(在 缓存重置 中不持久) |
:category |
类别。如果帖子未分类,它将使用 default_category 值。 |
:hash |
文件名(与 :title 相同)和日期(12 进制)的 SHA1 哈希值 |
你可以通过 permalink_defaults 设置定义永久链接中每个变量的默认值:
¥You can define the default value of each variable in the permalink through the permalink_defaults setting:
permalink_defaults: |
示例
¥Examples
title: Hello World |
| 设置 | 结果 |
|---|---|
:year/:month/:day/:title/ |
2013/07/14/hello-world/ |
:year-:month-:day-:title.html |
2013-07-14-hello-world.html |
:category/:title/ |
foo/bar/hello-world/ |
:title-:hash/ |
hello-world-a2c8ac003b43/ |
title: Hello World |
| 设置 | 结果 |
|---|---|
:year/:month/:day/:title/ |
2013/07/14/lorem/hello-world/ |
:year/:month/:day/:name/ |
2013/07/14/hello-world/ |
多语言支持
¥Multi-language Support
要创建多语言网站,你可以像这样修改 new_post_name 和 permalink 设置:
¥To create a multi-language site, you can modify the new_post_name and permalink settings like this:
new_post_name: :lang/:title.md |
当你创建新帖子时,帖子将保存到:
¥When you create a new post, the post will be saved to:
$ hexo new "Hello World" --lang tw |
URL 将是:
¥and the URL will be:
http://localhost:4000/tw/hello-world/ |