安裝hexo


title: 安裝hexo
date: 2016-04-23 15:54:25
categories: blog
tags: [hexo,github]


本文在查看網上各位網友的搭建情況下,編寫.更多作為補充功能.
本文環境: Windows 7

安裝Git

Git下載

注: 聽說新版本可能存在bug,所以盡可能安裝舊版本.

安裝Node.js

下載并安裝Node.js

重啟電腦

盡量在安裝完Node之后重啟電腦,否則后面可能會出現比較麻煩的問題.

安裝hexo

鼠標右鍵任意地方,選擇Git Bash,使用以下命令安裝hexo

$ hexo install hexo-cli -g

如果這里出現WARN并沒有關系.
使用以下命令,查看安裝是否成功:

$ hexo v

如果安裝成功,你就會看到各種版本信息:

hexo-cli: 1.0.1
os: Windows_NT 6.1.7601 win32 x64
http_parser: 2.5.2
node: 4.4.3
v8: 4.5.103.35
uv: 1.8.0
zlib: 1.2.8
ares: 1.10.1-DEV
icu: 56.1
modules: 46
openssl: 1.0.2g

如果不成功.那么你應該檢查你以上操作有沒有什么問題.多留意提示才是關鍵.

創建文件夾 E:\hexo, 并在這個文件夾內右鍵Git bash Here,執行命令:

$ hexo init

然后安裝依賴包:

$ hexo install

查看hexo文件夾帶來什么:

$ hexo g
$ hexo s

用瀏覽器訪問 (http://localhost:4000/ ) 此時,你應該看到了一個漂亮的本地博客.

注冊Github賬號

極其簡單.我不寫了. 假設這里創建的信息:
用戶名: xiaoming
注冊郵箱: xiaoming@163.com

創建repository

<strong>注意: 這里的repository 名稱只能為: xiaoming.github.io
千萬要注意!這里的名稱,是不能使用一個隨便的repository!!

部署本地文件到Github

編輯E:\hexo下的_config.yml文件
在文件的最后加入代碼:

deploy: 
  type: git
  repository: https://github.com/xiaoming/xiaoming.github.io.git
  branch: master
  

執行以下命令:

$ hexo g
$ hexo d

出現錯誤:
<strong>ERROR Deployer not found : git

執行命令:

$ npm install hexo-deployer-git --save
$ hexo g
$ hexo d

接下來又是一個錯誤, 這個錯誤是:

INFO  Deploying: git
INFO  Setting up Git deployment...
Initialized empty Git repository in E:/hexo/.deploy_git/.git/

*** Please tell me who you are.

Run

  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'dan@dan-PC.(none)')
FATAL Something's wrong. Maybe you can find the solution here: http://hexo.io/do
cs/troubleshooting.html
Error:
*** Please tell me who you are.

Run

  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'XXX@XXX-PC.(none)')

    at ChildProcess.<anonymous> (E:\hexo\node_modules\hexo-deployer-git\node_mod
ules\hexo-util\lib\spawn.js:37:17)
    at emitTwo (events.js:87:13)
    at ChildProcess.emit (events.js:172:7)
    at ChildProcess.cp.emit (E:\hexo\node_modules\hexo-deployer-git\node_modules
\hexo-util\node_modules\cross-spawn\node_modules\cross-spawn-async\lib\enoent.js
:37:29)
    at maybeClose (internal/child_process.js:827:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
FATAL

這個錯誤是因為當前本地的Git還沒配置用戶信息, 所以執行以下命令:

$ git config --global user.email "xiaoming@163.com"

$ git config --global user.name "xiaoming"

$ hexo d

此時,會要求輸入用戶名, 你就輸入你的用戶名: xiaoming
接著要求輸入密碼, 你就入密碼. 密碼輸入期間不會看到任何字符.然后直接回車即可.

結束

至此, 博客創建完成. 登陸網站: xiaoming.github.io 就可以看到啦!

常用命令備注:

$ hexo g #完整命令為hexo generate,用于生成靜態文件
$ hexo s #完整命令為hexo server,用于啟動服務器,主要用來本地預覽
$ hexo d #完整命令為hexo deploy,用于將本地文件發布到github上
$ hexo n #完整命令為hexo new,用于新建一篇文章
最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容