hexo部署github

GitHub设置

  1. 已经有了账号,本地也有sshkey,所以需要把id_rsa.pub文件的内容复制到账号–setting–”SSH and GPG keys”下面

  2. 验证是否成功的方式:ssh -T git@github.com  

  3. 进入github.com的网站,选择Repositories旁边的 New,输入uuair.github.io作为Repository name,下面选择 Add a README file,最后选 Create repository  

  4. 进入后选择 Settings,注意在GeneralDefault branch这里写的是什么,我的是main

  5. 选择Pages后,Source这里选择Deploy from a branch, Branch 这里选择main

  6. 同时上面的GitHub Pages这里会显示访问的地址:https://uuair.github.io

本地设置

  1. 下载nodejs
  2. 安装hexo: npm install hexo-cli -g
  3. 设置好本地目录:比如我的blog
  4. 1
    2
    3
    4
    hexo init blog
    cd blog
    npm install
    npm install hexo-deployer-git --save
  5. hexo命令:
    1
    2
    3
    4
    5
    hexo clean // 清空
    hexo g // g=generate 生成静态目录
    hexo d // d=deploy 发布
    hexo s // s=server 本地调试,浏览器localhost:4000
    hexo new test //发一篇文章
  6. 网站设置在文件 _config.yml中,下面是配置说明:
    • title :网站标题
    • subtitle: 副标题
    • description: 网站描述
    • author: 作者名字
    • language: zn-CN 网站语言
      每一个冒号后面跟一个英文的空格
    1. 配置主题:
      git clone https://github.com/cjquines/hexo-theme-ascent themes/ascent
    2. 修改 _config.ymlDeployment部分:
      1
      2
      3
      4
      5
      6
      # Deployment
      ## Docs: https://hexo.io/docs/one-command-deployment
      deploy:
      type: 'git'
      repo: git@github.com:uuair/uuair.github.io.git
        branch: main
    • repo的部分在github的 Code下面的 SSH中复制
    • branch必须跟settings中 GitHub Pages 指定的Branch一样
    1. 修改 themes 部分: theme: ascent
    2. 文章发布在 source/_posts中存为md格式
    3. source 目录下新建CNAME 文件,里面写上绑定的二级域名it.leon.vc,然后在settingsPages 下的Custom domain中验证域名,这样可以绑定域名.