//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"
: 添加分栏.