//Windows+R cmd C:\Users\student>node -v v9.9.0 C:\Users\student>npm -v 5.6.0 C:\Users\student>git --version git version 2.16.2.windows.1
新建項目(Github首頁->Start a project)
html
在一個合適的位置建立一個文件夾(別稱:根目錄),下文中由E:\Blog來演示.node
C:\Users\student>E: E:\>cd Blog E:\Blog>
E:\Blog>npm install hexo -g --save //WARN*3
檢查:git
E:\Blog>hexo -v hexo: 3.6.0 hexo-cli: 1.1.0 os: Windows_NT 6.1.7601 win32 ia32 http_parser: 2.7.0 node: 9.9.0 v8: 6.2.414.46-node.22 uv: 1.19.2 zlib: 1.2.11 ares: 1.13.0 modules: 59 nghttp2: 1.29.0 napi: 2 openssl: 1.0.2n icu: 60.2 unicode: 10.0 cldr: 32.0.1 tz: 2017c
E:\Blog>hexo init //WARN*2
檢查: 最後會顯示 INFO Start blogging with Hexo!github
E:\Blog>hexo install //WARN*2 E:\Blog>hexo g E:\Blog>npm install hexo-deployer-git --save //WARN*2
在根目錄下右鍵,選擇Git Bash Here.
若是第一次使用,輸入shell
student@XJ507011 MINGW32 /e/Blog $ git config --global user.name "NAME" student@XJ507011 MINGW32 /e/Blog $ git config --global user.email "EMAIL"
不然什麼都不幹.
接下來輸入:npm
$ ssh-keygen -t rsa -C "EMAIL" //連續三個回車 $ eval "$(ssh-agent -s)" $ ssh-add ~/.ssh/id_rsa
進入Github,點擊頭像下的Settings
,選擇SSH and GPS keys
,點擊New SSH key
.
Title:
任意, Key:
.ssh\id-rsa.pub的內容.(默認路徑爲: C:\Users\Administrator.ssh)
檢查:windows
student@XJ507011 MINGW32 ~ $ ssh -T git@github.com //若是還有要輸入的,回答yes. Hi oierlin! You've successfully authenticated, but GitHub does not provide shell access. //只要'Hi'後面是你的NAME,有warning也不要緊.
找到根目錄下的_config.yml
文件,在文本末尾你會找到deploy:
,
將其修改爲:api
deploy: type: git repository: git@github.com:NAME/NAME.github.io.git #or repository: https://github.com/NAME/NAME.github.io.git branch: master
repository
最好用前者,不然在hexo d -g
時有概率出現bash: /dev/tty: No such device or address
錯誤bash
E:\Blog>hexo d -g
將本地文件上傳到Github上.hexo
n--new
p--publish
g--generate
s--server
d--deploy
npm install hexo -g
npm update hexo -g
hexo init
hexo d -g
//上傳
hexo s
在http://localhost:4000/
查看
hexo n post "TITLE"
: 添加博客.
hexo n page "TITLE"
: 添加分欄.