hexo+github搭建博客系统

准备工作
  • 安装git
  • 创建github账号
  • nodejs(包含npm)
创建github仓库

仓库的名称是username.github.io其中username是你的用户名http://test.github.io

例如我创建的仓库名称为test,我就可以用http://test.github.io

配置sshkey

ssh-keygen -t rsa -C "邮件地址"

在用户目录下找到.ssh/id_rsa.pub文件,将内容复制到github中

配置全局用户

$ git config --global user.name "xxxx"// 你的github用户名,非昵称
$ git config --global user.email  "xxxx@xx.com"// 填写你的github注册邮箱
搭建hexo
  • 执行npm install -g hexo
  • 在某个地方创建目录,例如我在/home目录下创建blog目录
  • 执行hexo init /home/blog在blog目录下初始化hexo
  • 进入bolg目录
  • 编辑_config.yml修改URL部分
...
# URL
## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
url: https://test.github.io/
root: /home/blog/
permalink: :year/:month/:day/:title/
permalink_defaults:
...
上传的github
  • 依然修改_config.yml文件,修改Deployment部分
# Deployment
## Docs: https://hexo.io/docs/deployment.html
deploy:
  type: git
  repo: git@github.com:xxxx/test.github.io.git
  branch: master

注意:冒号后面要有空格,不然会出错

  • 执行 hexo g
  • 执行 hexo d
  • 如果出现奇怪的错误可以执行hexo clean清理一下
常用命令
hexo new "postName" #新建文章
hexo new page "pageName" #新建页面
hexo generate #生成静态页面至public目录
hexo server #开启预览访问端口(默认端口4000,'ctrl + c'关闭server)
hexo deploy #部署到GitHub
hexo help  # 查看帮助
hexo version  #查看Hexo的版本
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值