hexo模板初始化
mkdir test;cd test
#新建空目录
hexo init
初始化目录
导入主题,cd themes
例如导入这个主题:https://github.com/next-theme/hexo-theme-next
git clone https://github.com/next-theme/hexo-theme-next next
修改配置文件
leafpad /home/kali/Documents/Whale3070.github.io/_config.yml
修改为next,就是theme文件夹下的next文件夹
| # Extensions ## Plugins: https: ## Themes: https: theme: next
|
添加加密功能
-
npm install --save hexo-blog-encrypt
文件头这样设置
| --- title: Hello World tags: - encryptAsDiary date: 2016-03-30 21:12:21 password: mikemessi abstract: Here's something encrypted, password is required to continue reading. message: Hey, password is required here. wrong_pass_message: Oh, this is an invalid password. Check and try again, please. wrong_hash_message: Oh, these decrypted content cannot be verified, but you can still have a look. ---
|
博客迁移
之前是jekyll,因为jekyll的插件少,部分功能不方便
现在转而使用hexo
leafpad /home/kali/Documents/Whale3070.github.io/_config.yml
修改为new_post_name: :year-:month-:day-:title.md
hexo server -p 5010
更新图片地址
| cd /home/kali/Documents/Whale3070.github.io/source/_posts sed -i "s/images/img/g" *.md
|
修改md文件时间
cd /home/kali/Documents/Whale3070.github.io/source/_posts
ls > filename.txt
运行以下py脚本,即可自动更新jekyll博客的时间
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| import os import re
myre = '\d{4}-\d{2}-\d{2}-\d{2}' realtime = '\d{4}-\d{2}-\d{2}' yiliutime= '2016-\d{2}-\d{2}' yiqitime= '2017-\d{2}-\d{2}'
f = open('filename.txt','r') for i in f.readlines(): findtime=re.findall(myre,i) find2016time=re.findall(yiliutime,i) find2017time=re.findall(yiqitime,i) if len(findtime) > 0: findrealtime=re.findall(realtime,findtime[0]) #print(findrealtime) command = "sed -i \'2i date: "+findrealtime[0] + " 00:00:00 \' " + findtime[0] + "*.md" print(command) os.system(command) #if len(find2016time)>0: # command2 = "sed -i \'2i date: "+find2016time[0] + " 00:00:00 \' " + find2016time[0] + "*.md" # print(command2) # os.system(command2) #if len(find2017time)>0: # command3 = "sed -i \'2i date: "+find2017time[0] + " 00:00:00 \' " + find2017time[0] + "*.md" # print(command3) # os.system(command3)
|
参考资料