Kelf's Blog

悟已往之不谏,知来者之可追。

0%

hexo搭建静态博客

基本原理

  • Github Pages 寄存网页文件
  • Hexo将Markdown文件渲染成带有样式的HTML文件
    • 样式使用主题提供,例如Next就是一种主题

1. 安装Hexo,并初始化博客

我使用scoop安装的软件,所以这里的安装方式是基于scoop的。

  1. 安装Node.js

1
scoop install nodejs-lts

  1. 安装Git
1
scoop install git
  1. 安装Hexo
1
npm install -g hexo-cli
  1. 初始化博客
1
2
3
hexo init blog
cd blog
npm install
  1. 本地预览
1
hexo server

2. 配置主题

  1. 下载主题

使用 Next 主题

1
git clone https://github.com/theme-next/hexo-theme-next themes/next
  1. 配置主题

修改_config.yml文件

(1)选择next主题

1
theme: next

(2)修改url和root

1
2
url: https://Kelfvin.github.io
root: /

如果不修改,后面部署到Github Pages时主题无法生效

3.部署

  1. 配置_config.yml文件
1
2
3
4
deploy:
type: 'git'
repo: 'https://github.com/Kelfvin/Kelfvin.github.io'
branch: 'main'
  1. 安装hexo-deployer-git
1
npm install hexo-deployer-git --save
  1. 部署到Github Pages
1
2
3
hexo clean
hexo generate
hexo deploy