写在前面

Hexo是一个快速、简洁且高效的博客框架,我们可以简单部署在Github上来实现一个简单的个人博客,不过可能需要科学上网。

主要步骤

  1. 注册Github
  2. 安装Git
  3. 安装Node.js
  4. 安装Hexo
  5. 连接Github与本地
  6. 开始写博客

欢迎来到
我的博客

注册Github

https://github.com/

  1. 创建仓库:+ New repository

  2. 仓库名称: xxxxxxx.github.io

  3. 勾选README

  4. Settings→GitHub Pages→Choose a theme在这里插入图片描述

安装Git

https://git-scm.com/downloads

安装Node.js

https://nodejs.org/

安装Hexo

  1. 创建一个文件夹存放博客文件,在该文件夹内右键 Git Bash Here
  2. 可添加国内镜像源:npm config set registry https://registry.npm.taobao.org
    在这里插入图片描述
  1. 安装Hexo:npm i hexo-cli -g
    在这里插入图片描述

  2. 初始化:hexo init
    在这里插入图片描述

  3. 安装组件:npm install
    在这里插入图片描述

  4. 生成静态网页:hexo g
    在这里插入图片描述

  5. 打开本地服务器:hexo s
    在这里插入图片描述

  6. 浏览器:http://localhost:4000/

在这里插入图片描述

同步Github与本地

  1. 输入:git config --global user.name "用户名"

  2. 输入:git config --global user.email "邮箱"
    在这里插入图片描述

  3. 然后生成密钥SSH key:ssh-keygen -t rsa -C "邮箱"
    在这里插入图片描述

  4. 将生成的id_rsa.pub打开,复制内容
    在这里插入图片描述

  5. github首页→settings→SSH and GPG keys→new SSH keep→粘贴复制的内容
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述

  6. 输入:ssh -T git@github.com
    在这里插入图片描述

  7. 打开博客的配置文件_config.yml
    修改最后一行的配置:

1
2
3
4
deploy:
type: git
repository: 仓库地址
branch: master

在这里插入图片描述

开始写博客

  1. 首先在博客根目录下右键打开git bash
  2. 安装扩展:npm i hexo-deployer-git
  3. 新建文章:hexo new post "文章名"
    在这里插入图片描述
  4. 编写markdown文件
    在这里插入图片描述
  5. 生成静态网页:hexo g
  6. 打开本地服务器:hexo s
  7. 上传到github:hexo d
    在这里插入图片描述

结尾

这是Hexo+Github博客搭建的简单,还有很多功能可以拓展,有机会以后补充。