利用GitHub Pages免费创建个人博客

By | 2019-10-23

搭建环境:Windows10,需要安装 GitBash、Nodejs ,方法请自行搜索吧

1、去github官网注册账号https://github.com

2、点击右上角的➕号,Create a new repository,创建项目

3、建立与你用户名对应的仓库,仓库名必须为[username.github.io],固定写法

仓库名与用户名一样

4、安装好Git后打开,输入ssh-keygen -t rsa -C “github账号邮箱”,连续回车两次,生成key

5、打开用户目录生成的C:\Users\16838\.ssh\id_rsa.pub,复制key,为项目添加ssh key

ssh keys

6、测试是否本机与git连接
ssh -T git@github.com,如果输出You've successfully authenticated, but GitHub does not provide shell access.表示SSH已配置成功

7、配置账号邮箱
git config –global user.name “ github 用户名 ”
git config –global user.email “ github 注册邮箱 ”

下载配置HEXO

使用npm安装hexo,可以在gitbash里面输入

  1. npm install -g hexo-cli
  2. hexo init blog
  3. cd blog
  4. npm install

输入hexo server开启hexo服务,浏览器输入localhost:4000,能看到hexo hello world即表示可以使用Hexo了

hexo s

安装NEXT主题

  1. $ git clone https://github.com/iissnan/hexo-theme-next themes/next
  2. 打开站点配置文件_config.yml,找到theme字段,将之改为next
  3. 打开主题配置文件,将scheme改成Pisces
github next

提交站点

修改站点配置文件,添加仓库地址

deploy:
- type: git
  repository: git@github.com:bestminipc/bestminipc.github.io.git
  branch: master

安装hexo 插件

npm install hexo-deployer-git –save

站点根目录执行

hexo clean
hexo g -d

发表评论

邮箱地址不会被公开。 必填项已用*标注