搭建Hexo博客
安裝node.js
node官網(wǎng)下載
安裝git
- 使用homebrew安裝
安裝homebrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
安裝gitbrew install git
安裝hexo
sudo npm install -g hexo
新建Hexo文件夾-cd到該文件夾下
hexo init
生成靜態(tài)頁面
hexo generate
開啟本地服務(wù)器
hexo server
打開瀏覽器打開該網(wǎng)址
停止本地服務(wù)器
control + C
github上創(chuàng)建repository
命名方式username.github.io
安裝git部署器
Could not install /Users/Karen/Hexo/ --save
進入之前創(chuàng)建的Hexo文件夾打開_config.yml文件
在末尾修改如下KarenRen/KarenRen修改為你的用戶名
注意格式P汀功舀!
部署
hexo deploy
輸入用戶名密碼
打開https://username.github.io/
完成V遣!泊交!
接下來界面太丑我們來更換主題盗棵,很簡單仪壮,首先將選好的主題克隆下來翎猛,更改配置文件_config.yml就可以了勿锅。
克隆到Hexo->themes文件下
git clone https://github.com/litten/hexo-theme-yilia.git themes/yilia
修改配置具體見yilia博客
hexo-theme-yilia
這樣配置完成后每篇文字全部顯示,不夠簡潔皆警,想要做成目錄的樣子拦宣,也就是每篇文章只顯示部分怎么辦。
在md文件中加入這樣
以后的部分會被隱藏,點擊題目鸵隧,會進入到http://localhost:4000/2016/11/17/hello-world/
該文件下绸罗,也就是配置文件設(shè)置的permalink: :year/:month/:day/:title/
格式。
如果想要添加標(biāo)簽例如:
很簡單豆瘫,在md文件中添加如下內(nèi)容即可
常見問題匯總:
Hexo d部署的時候ERROR
提示ERROR Deployer not found: git
兩種情況:
- Hexo 3.0之后deploy的type 的github需要改成git
- 可能像我一樣重新init Hexo 丟失了git
總之執(zhí)行npm install hexo-deployer-git --save
即可