记录:hexo 搭建个人博客并部署到 Github

Hexo 简介

A fast, simple & powerful blog framework

Hexo 是一个快速、简洁且高效的博客框架。Hexo 使用 Markdown(或其他渲染引擎)解析文章,在几秒内,即可利用靓丽的主题生成静态网页。

详情请参见:
Hexo 英文官网
Hexo 中文官网

环境/工具

  • OS: Win10
  • Node.js
  • Git

安装 Hexo 流程

  • npm 全局安装 Hexo:npm install hexo-cli -g,hexo: 3.3.9
  • 切换到一个目标空文件夹:cd <folder>
  • 执行:hexo init
  • 执行:npm install,安装 Hexo 的依赖包(貌似不需要,hexo init 帮我们完成了),生成的目录结构如下

    1
    2
    3
    4
    5
    6
    7
    8
    9
    .
    ├── _config.yml
    ├── package.json
    |── node_modules
    ├── scaffolds
    ├── source
    | ├── _drafts
    | └── _posts
    └── themes
  • 执行:hexo serve,将默认启动一个服务器,浏览器输入地址:http://localhost:4000,将会打开你的博客内容

部署到 Github

  • github 的 SSH keys 配置:参见

  • Hexo 安装依赖: npm install hexo-deployer-git --save
    该依赖解决执行 hexo deploy 后,出现的 error deployer not found:git 的错误

  • 修改 _config.yml 文件

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    # Deployment
    ## Docs: https://hexo.io/docs/deployment.html
    deploy:
    type:
    branch:
    修改为:
    # Deployment
    ## Docs: https://hexo.io/docs/deployment.html
    deploy:
    type: git
    repository: https://github.com/你的github账户名/你的github账户名.github.io.git
    branch: master
  • 执行:hexo g -d,将博客内容同步到 Github 上,在浏览器地址栏输入 ‘https://你的github用户名.github.io/‘ 即可看到你的博客

×

纯属好玩

扫码支持
扫码打赏,你说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

,