搭建博客

  1. 环境
    Windows子系统(Arch)

  2. 安装hexo

    1
    2
    3
    4
    5
    6
    7
    安装
    sudo pacman -S nodejs
    sudo pacman -S npm
    npm install -g hexo-cli --registry=https://registry.npmmirror.com

    测试
    hexo -v
  3. GitHub创建用户名.github.io仓库

  4. 设置密钥

    1
    2
    3
    sudo pacman -S openssh
    ssh-keygen -t rsa -C "924084608@qq.com"
    cat .ssh/id_rsa.pub
  5. 将密钥添加至GitHub

  6. 验证是否成功添加

    1
    ssh -T git@github.com
  7. 本地部署

    1
    2
    3
    4
    5
    6
    7
    8
    cd /mnt/d/92408/Documents/Blog/
    npx hexo init 初始化
    npx hexo install 安装
    hexo new "My New Post" 创建文章
    npx hexo clean 清理缓存
    npx hexo g 生成
    npx hexo d 上传
    npx hexo s 本地部署
  8. 上线博客

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    vim _config.yml
    # Deployment
    ## Docs: https://hexo.io/docs/one-command-deployment
    deploy:
    type: git
    repository: git@github.com:xinxiaoyu1/xinxiaoyu1.github.io.git
    branch: main

    git config --global user.email "924084608@qq.com"
    git config --global user.name "xinxiaoyu1"

    npx hexo d

    遇到报错请安装hexo-deployer-git插件:## ERROR Deployer not found: git
    npm install hexo-deployer-git --save --registry=https://registry.npmmirror.com
  9. 访问网站测试
    Hexo (xinxiaoyu1.github.io)