GitHub Pages + Hexo 创建个人博客

所需环境

  1. git
  2. node.js
  3. Hexo (在Node.js中安装)
  4. hexo-deployer-git (npm install hexo-deployer-git --save)

1. Github创建个人仓库

登录到GitHub,在Github中新建一个Repository,Repository名称应为:your_github_name.github.io。Repository名称格式固定,不能改变,比如我的仓库名称如下:
在这里插入图片描述
目前Git Push代码时可能遇到如下问题:

remote: Support for password authentication was removed on August 13, 2021. Please use a personal access token instead.
remote: Please see https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/ for more information.

密码需要在Github Setting中Developer settings里的Personal access token中生成

2. 使用Hexo 初始化博客

输入以下命令初始化博客,完成后可以在localhost:4000端口查看。

hexo init blog

hexo new first_blog //新建一个md

hexo g // hexo generate -> 生成一个名为first_blod的md文件

hexo s // hexo server -> 启动服务、预览

3. 将Hexo与Github相关联

修改hexo生成文件夹中的_config.yml文件添加如下内容

deploy:
  type: git
  repo: https://github.com/limbolism/limbolism.github.io.git
  branch: master

4. 推送更新至Github仓库

首先安装插件npm install hexo-deployer-git --save。然后清空刚才的测试文件。推送新的至仓库

hexo clean 

hexo g

hexo d // hexo deploy

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值