怎样将Hexo与github page 联系起来

原文地址:http://blog.csdn.net/gdutxiaoxu/article/details/53576018

怎样将Hexo与github page 联系起来

大概分为以下几步 
- 配置git个人信息 
- 配置Deployment

配置Git个人信息

如果你之前已经配置好git个人信息,请跳过这一个 步骤,直接来到

1、设置Git的user name和email:(如果是第一次的话)

git config --global user.name "kim-yhow"
git config --global user.email "564223274@qq.com"
 
 
  • 1
  • 2
  • 1
  • 2

2、生成密钥

 ssh-keygen -t rsa -C "564223274@qq.com"
 
 
  • 1
  • 1

配置Deployment

同样在_config.yml文件中,找到Deployment,然后按照如下修改:

deploy:
  type: git
  repo: git@github.com:yourname/yourname.github.io.git
  branch: master
 
 
  • 1
  • 2
  • 3
  • 4
  • 1
  • 2
  • 3
  • 4

比如我的仓库的地址是git@github.com:gdutxiaoxu/gdutxiaoxu.github.io.git,所以配置如下

deploy:
  type: git
  repo: git@github.com:gdutxiaoxu/gdutxiaoxu.github.io.git
  branch: master
 
 
  • 1
  • 2
  • 3
  • 4
  • 1
  • 2
  • 3
  • 4

  • 注意需要提前安装一个扩展:
npm install hexo-deployer-git --save
 
 
  • 1
  • 1

如果没有执行者行命令,将会提醒

deloyer not found:git




写博客、发布文章

新建一篇博客,执行下面的命令:

hexo new post "article title"
 
 
  • 1
  • 1

这时候在我的 电脑的目录下 F:\hexo\source_posts 将会看到 article title.md 文件

用MarDown编辑器打开就可以编辑文章了。文章编辑好之后,运行生成、部署命令:

hexo g   // 生成
hexo d   // 部署
 
 
  • 1
  • 2
  • 1
  • 2

当然你也可以执行下面的命令,相当于上面两条命令的效果

hexo d -g #在部署前先生成
 
 
  • 1
  • 1

部署成功后访问 你的地址,https://yourName.github.io(这里输入我的地址: https://kim-yhow.github.io ),将可以看到生成的文章。

踩坑提醒

  • 1)注意需要提前安装一个扩展:
npm install hexo-deployer-git --save
 
 
  • 1
  • 1

如果没有执行者行命令,将会提醒

deloyer not found:git

2)如果出现下面这样的错误,

Permission denied (publickey). 
fatal: Could not read from remote repository. 
Please make sure you have the correct access rights 
and the repository exists.

则是因为没有设置好public key所致。 


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值