Hexo Next 博客系统搭建及常用操作指南
一、环境准备
首先需要安装必要的环境:
安装完成后,通过命令行验证:
二、Hexo 与 Next 主题搭建步骤
- 安装 Hexo 脚手架
- 初始化博客项目
1 2 3 4 5 6 7 8
| mkdir my-hexo-blog && cd my-hexo-blog
hexo init
npm install
|
- 安装 Next 主题
1 2
| git clone https://github.com/next-theme/hexo-theme-next themes/next
|
- 配置 Next 主题
编辑博客根目录下的 _config.yml:
1 2 3 4 5 6 7 8 9 10
| theme: next
title: 我的博客 subtitle: '' description: '' author: 你的名字 language: zh-CN timezone: Asia/Shanghai
|
- 初始化博客并预览
1 2 3 4 5
| hexo generate
hexo server
|
访问 http://localhost:4000 即可预览博客
三、常用命令
- 基础命令
1 2 3 4 5
| hexo new "文章标题" hexo generate hexo server hexo deploy hexo clean
|
- 组合命令
1 2
| hexo clean && hexo g -d hexo s -g
|
四、新增与发布文章
- 创建新文章
1 2 3 4 5
| hexo new "我的第一篇博客"
hexo new page "about"
|
文章会生成在 source/_posts/ 目录下,格式为 Markdown
- 编辑文章
Markdown 文章头部包含 Front-matter 配置:
1 2 3 4 5 6 7 8 9 10 11
| --- title: 我的第一篇博客 date: 2025-09-01 10:00:00 tags: - 教程 - Hexo categories: - 技术 ---
这里是文章内容...
|
- 部署到远程(以 GitHub Pages 为例)
- 配置
_config.yml 中的 deploy 部分:
1 2 3 4
| deploy: type: git repo: https://github.com/你的用户名/你的用户名.github.io.git branch: main
|
1
| npm install hexo-deployer-git --save
|
五、其他常用操作
- 设置 Next 主题样式
编辑 themes/next/_config.yml 可配置主题样式:
1 2 3 4 5 6 7 8
| scheme: Gemini
toc: enable: true
|
- 添加标签和分类页面
1 2
| hexo new page tags hexo new page categories
|
然后在对应页面的 Markdown 文件中添加类型声明
- 更新 Next 主题
通过以上步骤,你可以完成 Hexo Next 博客的搭建并掌握日常管理维护的基本操作