hello hexo on github

hexo命令

安装

hexo,命令安装

1
$ npm install -g hexo

初始化

1
$ hexo init

新建文章

1
$ hexo new "hello wenqy"

生成静态页面

1
$ hexo generate

启动本地服务

1
$ hexo server

默认端口:4000

github部署

修改配置文件

修改全局配置文件:_config.yml

1
2
3
4
deploy:
type: git
repo: http://github.com/wenqy/wenqy.gihub.io.git
branch: master

部署

github上创建wenqy.gihub.io仓库

1
$ npm install hexo-deployer-git --save

可以使用SSH Keys,然后执行

1
$ hexo deploy

前置条件

git

安装git[git-for-windows.github.io](http://git-for-windows.github.io),配置git环境变量

ssh keys

keys生成

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
xmn-wenqy@G-FJ-XMN-WQY MINGW64 ~
$ cd ~

xmn-wenqy@G-FJ-XMN-WQY MINGW64 ~
$ ssh-keygen -t rsa -C "xxxxxx@xx.com" #邮箱
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/xxx/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/xxx/.ssh/id_rsa.
Your public key has been saved in /c/Users/xxx/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:xxxxx xxxxxx@xx.com
The key's randomart image is:
+---[RSA 2048]----+
| xxxx|
+----[SHA256]-----+

xmn-wenqy@G-FJ-XMN-WQY MINGW64 ~
$ ssh-keygen -t rsa -C "xxxxxx@xx.com" -f ~/.ssh/github_blog_keys #指定文件
Generating public/private rsa key pair.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/xxx/.ssh/github_blog_keys.
Your public key has been saved in /c/Users/xxx/.ssh/github_blog_keys.pub.
The key fingerprint is:
SHA256:xxxxx xxxxxx@xx.com
The key's randomart image is:
+---[RSA 2048]----+
|xxxx |
+----[SHA256]-----+

xmn-wenqy@G-FJ-XMN-WQY MINGW64 ~
$ git config --global user.name "wenqy"

xmn-wenqy@G-FJ-XMN-WQY MINGW64 ~
$ git config --global user.email "xxxxx@xx.com"

xmn-wenqy@G-FJ-XMN-WQY MINGW64 ~
$ ssh -T git@github.com #测试
The authenticity of host 'github.com (192.30.252.121)' can't be established.
RSA key fingerprint is SHA256:xxxx.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,192.30.252.121' (RSA) to the list of known hosts.
Hi wenqy! You've successfully authenticated, but GitHub does not provide shell access.

xmn-wenqy@G-FJ-XMN-WQY MINGW64 ~
$

github上设置里新建ssh keys,将生成的pub公钥内容复制过去,然后测试是否可通

然后查看部署wenqy.github.io