一篇带你使用 github pages + hexo 快速搭建个人博客

1. 创建一个名为 <账户名>.github.io 的仓库

2. 新建 index.html 文件

内容为:

<!-- index.html -->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>my blog</title>
</head>
<body>
    <h1>this is my blog</h1>
    <h1>Hello ~</h1>
</body>
</html>

3. 访问主页

4. 搭建 hexo

  1. 安装 hexo
    npm install -g hexo-cli
    hexo init <project-name>
    cd <project-name>
    npm install
  2. 本地启动
    hexo g && hexo s
    控制台看到如下即启动成功 访问 http://localhost:4000/

5. 将 hexo 发布到 github pages

  1. 安装 hexo-deployer-git
    npm install hexo-deployer-git --save
  2. 在 _config.yml 中添加以下配置
    deploy:
      type: git
      repo: git@github.com:mmmying/mmmying.github.io.git
      branch: main
  3. 执行 hexo clean && hexo deploy 
  4. 浏览 <username>.github.io,检查网站能否运作 手机上访问效果