鍍金池/ 教程/ HTML/ 永久鏈接(Permalinks)
配置
本地化(i18n)
建站
輔助函數(shù)(Helpers)
主題
服務(wù)器
指令
數(shù)據(jù)文件
模版
部署
遷移
標(biāo)簽插件(Tag Plugins)
Front-matter
生成文件
貢獻(xiàn)
問(wèn)題解答
變量 | Hexo
資源文件夾
插件
寫作
永久鏈接(Permalinks)

永久鏈接(Permalinks)

您可以在配置中調(diào)整網(wǎng)站的永久鏈接。

變量

除了下列變量外,您還可使用 Front-matter 中的所有屬性。

變量 描述
:year 文章的發(fā)表年份(4 位數(shù))
:month 文章的發(fā)表月份(2 位數(shù))
:i_month 文章的發(fā)表月份(去掉開頭的零)
:day 文章的發(fā)表日期 (2 位數(shù))
:i_day 文章的發(fā)表日期(去掉開頭的零)
:title 文件名稱
:id 文章 ID
:category 分類。如果文章沒有分類,則是 default_category 配置信息。

您可在 permalink_defaults 參數(shù)下調(diào)整永久鏈接中各變量的默認(rèn)值:

    permalink_defaults:
      lang: en  

示例

假設(shè) source/_posts 文件夾中有個(gè) hello-world.md,包含以下內(nèi)容:

    title: Hello World
    date: 2013-07-14 17:01:34
    categories:
    - foo
    - bar  
參數(shù) 結(jié)果
: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

多語(yǔ)種支持

若要建立一個(gè)多語(yǔ)種的網(wǎng)站,您可修改 new_post_namepermalink 參數(shù),如下:

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

當(dāng)您建立新文章時(shí),文章會(huì)被儲(chǔ)存到:

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

而網(wǎng)址會(huì)是:

    http://localhost:4000/tw/hello-world/  
上一篇:問(wèn)題解答下一篇:生成文件