Permalinks

  • 2018-12-03

You can specify the permalinks for your site in _config.yml or in the front-matter for each post.

Variables

Besides the following variables, you can use any attributes in the permalink.

Variable Description
:year Published year of posts (4-digit)
:month Published month of posts (2-digit)
:i_month Published month of posts (Without leading zeros)
:day Published day of posts (2-digit)
:i_day Published day of posts (Without leading zeros)
:title Filename
:id Post ID
:category Categories. If the post is uncategorized, it will use the default_category value.

You can define the default value of each variable in the permalink through the permalink_defaults setting:

1
2
permalink_defaults:
lang: en

Examples

Given a post named hello-world.md in the source/_posts folder with the following content.

1
2
3
4
5
title: Hello World
date: 2013-07-14 17:01:34
categories:
- foo
- bar
Setting Result
: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

Multi-language Support

To create a multi-language site, you can modify the new_post_name and permalink settings like this:

1
2
new_post_name: :lang/:title.md
permalink: :lang/:title/

When you create a new post, the post will be saved to:

1
2
$ hexo new "Hello World" --lang tw
# => source/_posts/tw/Hello-World.md

and the URL will be:

1
http://localhost:4000/tw/hello-world/

扫码领红包

2018双11超级红包
PC访问链接: 2018双11超级红包 预售开启 汇聚全球潮流新品

淘口令:¥20Y0b6q4eHR¥ (复制此行再打开手机淘宝客访问)

最后更新: 2018年12月03日 09:29

原始链接: https://cyc.oy99.com/docs/permalinks.html

× 多少都行~
打赏二维码
×
  • {title}