1. 程式人生 > 其它 >Hexo部落格文章唯一連結

Hexo部落格文章唯一連結

Hexo的預設文章連結格式是年,月,日,標題這種格式來生成的。如果你的標題是中文的話,那你的URL連結就會包含中文。

複製後的URL路徑就是把中文變成了一大堆字串編碼,如果你在其他地方用這邊文章的url連結,偶然你又修改了改文章的標題,那這個URL連結就會失效。為了給每一篇文章來上一個屬於自己的連結,寫下此教程,利用 hexo-abbrlink 外掛,A Hexo plugin to generate static post link based on post titles ,來解決這個問題。

參考github官方: hexo-abbrlink 按照此教程配置完之後如下:

  1. 安裝外掛,在部落格根目錄 [Blogroot] 下開啟終端,執行以下指令:
npm install hexo-abbrlink --save
  1. 修改 config.yml 檔案中的永久連結:
permalink: posts/:abbrlink/ 
# or
permalink: posts/:abbrlink.html

有兩種設定:

alg -- Algorithm (currently support crc16 and crc32, which crc16 is default)
rep -- Represent (the generated link could be presented in hex or dec value)

例如:

# abbrlink config
abbrlink:
  alg: crc32      #support crc16(default) and crc32
  rep: hex        #support dec(default) and hex

最終生成的文章名是根據文章的釋出時間戳生成的。


參考文章:

  1. rozbo/hexo-abbrlink: create one and only link for every post for hexo