Hexo博客搭建简单步骤


Hexo 博客搭建及部署简单步骤

一、博客项目搭建

  1. 安装 Node 环境

  2. 安装 hexo 博客脚手架

  3. 博客项目初始化

    • 新建本地文件夹如 blog
    • 在此文件夹启动命令行
    • 输入 hexo init
  4. 博客项目启动

    • 在 blog 文件夹下的命令行输入 hexo serve 或 hexo s

二、部署到 Github

  1. 新建 github 账号

  2. 配置 SSH Key

    ① 设置 git 的 user name 和 email

    • git config –global user.name “自己的 git 用户名”
    • git config –global user.email “自己的 git 邮箱”

    ② 检查是否存在 SSH Key

    • 查看 C:\Users\计算机名.ssh 中是否有 id_rsa 和 id_rsa.pub

    ③ 如果没有 SSH Key,则生成

    • ssh-keygen -t rsa -C “个人 git 邮箱”

    ④ 获取 SSH Key

    • 打开 id_rsa.pub 并复制

    ⑤ GitHub 账户添加 SSH Key

    • 在 setting 中的 SSH and GPG Keys 中新建 SSH Key

    ⑥ 验证

  3. 新建仓库

  • 注意:仓库地址必须和用户地址相同,因为公网访问的时候需要
  1. 安装部署插件 hexo-deployer-git

    • npm install –save hexo-deployer-git
  2. 设置_config.yml

    • deploy

      • type:git
      • repo:仓库地址
      • branch: master
  3. 部署到远端

    • 执行 hexo deploy 或 hexo d

三、新建博客

  1. 执行 hexo new “博客名” 或者 hexo n “博客名”

    • 在 source/_posts 目录下即可看到新博客的 md 文件
  2. hexo clean(清理) → hexo g(生成)→ hexo s(启动)

四、更换主题

  1. 下载主题

    • git clone “主题 git 地址” theme/yilia

    • 修改_config.yml 文件中的 theme:yilia

    • 重新清理 → 生成 → 启动 → 部署到远端


文章作者: AlfaLee
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 AlfaLee !
  目录