logo
0
0
WeChat Login

Hexo博客搭建指南

📦 项目简介

本项目是基于Hexo 8.0.0的博客框架,已配置好基本的运行环境。

当前主题: 🌸 hexo-theme-reimu v1.12.0(博丽灵梦风格主题)

🔧 环境要求

  • Node.js: v20.20.0
  • npm: v10.8.2
  • Git: v2.39.5

🚀 快速开始

1. 加载Node.js环境

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"

2. 启动本地服务器(使用Reimu主题)

cd /workspace/blog
./start-reimu.sh

或使用传统方式:

cd /workspace/blog
hexo clean && hexo g && hexo s

访问地址:http://localhost:4000

3. 创建新文章

hexo new "文章标题"

文章会创建在 source/_posts/ 目录下。

4. 生成静态文件

hexo generate
# 或简写为
hexo g

生成的静态文件在 public/ 目录。

5. 部署博客

hexo deploy
# 或简写为
hexo d

📁 项目结构

blog/
├── _config.yml          # Hexo主配置文件
├── _config.landscape.yml # 主题配置文件
├── package.json         # 项目依赖配置
├── scaffolds/           # 文章模板
│   ├── draft.md        # 草稿模板
│   ├── page.md         # 页面模板
│   └── post.md         # 文章模板
├── source/             # 源文件目录
│   ├── _posts/         # 文章目录
│   │   └── hello-world.md
│   └── _drafts/        # 草稿目录(如存在)
├── themes/             # 主题目录
│   └── landscape/      # 默认主题
└── public/             # 生成的静态文件(生成后创建)

⚙️ 常用命令

命令说明
hexo n "文章名"新建文章
hexo clean清理缓存和生成的文件
hexo g生成静态文件
hexo s启动本地服务器
hexo d部署到远程服务器
hexo publish "草稿名"发布草稿

🎨 自定义配置

修改博客信息

编辑 _config.yml 文件:

title: 你的博客标题
subtitle: 副标题
description: 博客描述
author: 作者名
language: zh-CN  # 语言设置为中文
timezone: Asia/Shanghai  # 时区设置为上海

修改主题

当前使用 hexo-theme-reimu 主题(博丽灵梦风格)。

主题配置文件位于 themes/hexo-theme-reimu/_config.yml

详细配置请查看:REIMU_THEME_GUIDE.md

如果需要更换主题:

  1. themes/ 目录安装新主题
  2. 修改根目录 _config.yml 中的 theme 字段

🔍 常见问题

1. npm install 失败

解决方案:

npm install --registry=https://registry.npmmirror.com

2. 端口4000被占用

修改 _config.yml 中的端口配置,或在启动时指定端口:

hexo server -p 4001

3. 文章不显示

确保文章使用正确的Front Matter格式:

---
title: 文章标题
date: 2026-01-28 14:00:00
tags: [标签1, 标签2]
categories: 分类
---

文章内容...

4. 生成速度慢

# 清理缓存后重新生成
hexo clean
hexo generate

5. 图片无法显示

确保图片路径正确,建议将图片放在 source/images/ 目录下:

![图片说明](/images/pic.jpg)

📚 推荐插件

搜索插件

npm install hexo-generator-searchdb

RSS订阅

npm install hexo-generator-feed

Sitemap生成

npm install hexo-generator-sitemap

压缩插件

npm install hexo-neat

🌐 部署到GitHub Pages

1. 安装部署插件

npm install hexo-deployer-git --save

2. 修改配置

编辑 _config.yml

deploy:
  type: git
  repo: https://github.com/username/username.github.io.git
  branch: main

3. 部署

hexo clean
hexo g
hexo d

💡 写作技巧

Front Matter 参数

---
title: 文章标题
date: 2026-01-28 14:00:00  # 创建时间
updated: 2026-01-28 15:00:00  # 更新时间
comments: true  # 是否开启评论
tags: [标签1, 标签2]
categories: 分类
permalink: 自定义链接
---

插入代码

\`\`\`javascript
console.log('Hello Hexo!');
\`\`\`

插入图片

![图片说明](/images/pic.jpg)

📖 参考资料

🎉 开始写作

现在你可以开始创建你的第一篇博客了:

hexo new "我的第一篇博客"

编辑 source/_posts/我的第一篇博客.md 文件,然后:

hexo clean
hexo g
hexo s

访问 http://localhost:4000 查看你的博客!


祝写作愉快! 📝✨

About

No description, topics, or website provided.
Language
Shell95%
Dockerfile5%