Skip to content

Xdddyy/dylan.github.io

Repository files navigation

个人博客

这是一个基于 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。

GitHub Pages 发布流程

  1. 确认 _config.yml 中的站点地址为当前 GitHub Pages project site:
    • url: https://Xdddyy.github.io/dylan.github.io
    • root: /dylan.github.io/
  2. 确认 GitHub 远端仓库已经绑定:
git remote -v

如果没有远端仓库,执行:

git remote add origin https://github.com/Xdddyy/dylan.github.io.git
  1. 提交源码并推送到 main 分支:
git add -A
git commit -m "Update blog content"
git push -u origin main
  1. 打开 GitHub 仓库的 Settings -> Pages,将 Source 设置为 GitHub Actions
  2. 进入 Actions 页面,等待 Pages 工作流执行完成。
  3. 发布成功后访问 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

About

个人博客

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors