安裝依賴環境
- git
- npm
- nodejs
安裝git
sudo apt install git
安裝npm
sudo apt install npm
安裝nodejs
sudo apt install nodejs
安裝Hexo
npm install -g hexo-cli
hexo的使用
hexo init folder
初始化一個文件夾作爲你的blog
hexo new file
在/folder/source/_posts/路徑下新建一個file.md文件
hexo s
打開本地預覽,在http://localhost:4000預覽博客
修改Hexo主題
你可以在Themes|Hexo下載你喜歡的主題,將下載好的主題文件夾移動到/folder/themes/
下
git clone theme's site
你可以添加about,tags,categories,contact等信息:
hexo new page about
hexo new page tags
hexo new page categories
hexo new page contact
修改/folder/_config.yml
完成主題的更換
theme: your theme
在/folder/themes/your theme
可以選擇配置你的主題樣式,如果你會CSS,你也可以修改主題的樣式模板
部署到github遠端
添加你的github信息
git config --global user.name "yourname"
git config --global user.email "youremail"
創建ssh
ssh-keygen -t rsa -C "youremail"
在~/.ssh/
文件夾中存在id_rsa
和id_rsa.pub
兩個文件,其中id_rsa.pub
是公鑰,把它複製粘貼到github上:
setting > SSH and GPG keys > New SSH key
— 粘貼
安裝deploy-git
npm install hexo-deployer-git --save
修改/folder/_config.yml文件:
deploy:
type: 'git'
repo: https://github.com/yourGithub/yourGithub.github.io.git
branch: master
推送到遠端
hexo d
- 通過
hexo clean
可以清除之前生成的內容 - 通過
hexo g
生成靜態博客
更多教程請參考Documentation|Hexo
附上我的hexo博客