Hexo简介

静态的博客框架,能够把markdown渲染成静态网页托管到GitHub上

  • 检查node和npm版本
1
2
node -v
npm -v
  • 更换hexo镜像源
1
npm config set registry https://registry.npmmirror.com
  • 执行安装 hexo-cli 的命令
1
npm install -g hexo-cli
  • 初始化
1
hexo init my-blog
  • 执行进入 my-blog 目录的命令
1
cd my-blog
  • 执行 npm install 命令来安装博客项目的依赖
1
npm install

本地预览博客命令

1
2
hexo generate
hexo server

_config.yml文件为博客的全局配置文件
source文件下放置为要发表的文件
theme文件夹放置为主题文件

初始化git

  1. 新建git仓库,仓库名字:用户名+github.io
  2. 初始化仓库
1
2
3
4
5
6
7
echo "# unicorn777-bot.github.io" >> README.md
git init
git add .
git commit -m "first commit"
git branch -M main
git remote add origin https://github.com/unicorn777-bot/unicorn777-bot.github.io.git
git push -u origin main

修改_config.yml最后配置

1
2
3
4
deploy:
  type: git
  repository: [email protected]:unicorn777-bot/unicorn777-bot.github.io.git
  branch: main
  • 安装hexo-deployer-git插件
1
npm install hexo-deployer-git --save

创建一篇新博客文章

1
hexo new post xxx

三合一命令

清理渲染数据+生成新的渲染数据

1
cd my-blog; hexo clean; hexo generate; hexo deploy

Hexo-pro步骤

1
2
3
4
5
6
1. 安装 Hexo-Pro 插件
npm install --save hexo-pro
2. 启动 Hexo 服务器
hexo server -d
3.访问后台管理页面
open http://localhost:4000/pro/