这是一个基于 Hexo 8、Matery 主题和 GitHub Pages 的个人博客项目。源码仓库为 Xdddyy/dylan.github.io,提交到 main 分支后,GitHub Actions 会自动构建静态文件并发布到 GitHub Pages。
- Hexo
^8.1.2 - Node.js
22 - Matery 主题:
blinkfox/hexo-theme-matery - GitHub Pages:通过
.github/workflows/pages.yml自动发布
首次拉取项目后安装依赖:
npm install启动本地预览服务:
npm run server浏览器打开 http://localhost:4000 即可预览博客。
本地构建静态站点:
npm run build构建产物会生成到 public/ 目录。该目录只作为本地构建结果,不需要提交到 Git。
- 确认
_config.yml中的站点地址为当前 GitHub Pages project site:url: https://Xdddyy.github.io/dylan.github.ioroot: /dylan.github.io/
- 确认 GitHub 远端仓库已经绑定:
git remote -v如果没有远端仓库,执行:
git remote add origin https://github.com/Xdddyy/dylan.github.io.git- 提交源码并推送到
main分支:
git add -A
git commit -m "Update blog content"
git push -u origin main- 打开 GitHub 仓库的
Settings -> Pages,将Source设置为GitHub Actions。 - 进入
Actions页面,等待Pages工作流执行完成。 - 发布成功后访问
https://Xdddyy.github.io/dylan.github.io。
推荐使用 Hexo 命令创建文章:
npx hexo new post "文章标题"命令会在 source/_posts/ 下创建一个 Markdown 文件。也可以手动在该目录新建 .md 文件,但需要保留文章头部信息,例如:
---
title: 文章标题
date: 2026-07-06 14:00:00
author: 你的名字
categories:
- 分类名称
tags:
- 标签名称
summary: 文章摘要
toc: true
mathjax: false
---
这里开始编写正文。写完后按下面流程检查并发布:
npm run server
npm run build
git add source/_posts/ package-lock.json package.json _config.yml README.md
git commit -m "Add new blog post"
git push如果只新增文章,通常只需要提交 source/_posts/ 下的新文件。推送到 GitHub 后,Pages 工作流会自动重新构建并发布。
- 博客文章:
source/_posts/ - 关于页面:
source/about/index.md - 分类页面:
source/categories/index.md - 标签页面:
source/tags/index.md - 友链页面:
source/friends/index.md - 友链数据:
source/_data/friends.json - 主题目录:
themes/hexo-theme-matery
本项目将 Matery 主题作为 Git 子模块管理。克隆项目时建议使用:
git clone --recurse-submodules <repo-url>如果已经克隆但主题目录为空,执行:
git submodule update --init --recursive