突然心血來潮,想搭建一個博客,就在網(wǎng)上查了一些資料,決定用hexo+Github來搭建。
記錄一下搭建過程。
博客地址
安裝前提
確保電腦安裝下列程序:
- Node.js
- Git
安裝Hexo
輸入下面命令安裝Hexo
npm install -g hexo-cli
建站
輸入下面命令初始化
hexo init <folder>
cd <folder>
npm install
新建完成后的文件夾目錄

文件夾目錄
生成靜態(tài)文件
hexo generate
啟動本地服務(wù)器,進(jìn)行文章調(diào)試預(yù)覽
hexo server
瀏覽器中輸入http://localhost:4000 預(yù)覽
部署
安裝hexo-deployer-git。
npm install hexo-deployer-git --save
修改_config.yml配置
deploy:
type: git
repo: <repository url> //庫(Repository)地址
branch: [branch]
message: [message]
部署
hexo deploy
每次部署步驟
hexo clean
hexo generate
hexo deploy
一些常用命令
hexo new "postName" #新建文章
hexo new page "pageName" #新建頁面
hexo generate #生成靜態(tài)頁面至public目錄
hexo server #開啟預(yù)覽訪問端口(默認(rèn)端口4000,'ctrl + c'關(guān)閉server)
hexo deploy #將.deploy目錄部署到GitHub
hexo help #查看幫助
hexo version #查看Hexo的版本
修改主題
下載
$ git clone https://github.com/giscafer/hexo-theme-cafe.git themes/cafe
使用
修改博客配置文件 `_config.yml` 主題屬性 theme 為 `cafe`.
更新升級
cd themes/cafe
git pull