<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="zh_CN">
  <title>Eira</title>
  <subtitle>Personal Space</subtitle>
  <link href="https://eirayun.top/" rel="alternate" type="text/html"/>
  <link href="https://eirayun.top/atom.xml" rel="self" type="application/atom+xml"/>
  <id>https://eirayun.top/</id>
  <updated>2026-10-18T00:00:00.000Z</updated>
  <entry>
    <title>在 Hexo + Butterfly 中渲染 Mermaid 图表</title>
    <link href="https://eirayun.top/posts/hexo-butterfly-%E6%B8%B2%E6%9F%93-mermaid/" rel="alternate" type="text/html"/>
    <id>https://eirayun.top/posts/hexo-butterfly-%E6%B8%B2%E6%9F%93-mermaid/</id>
    <published>2026-10-18T00:00:00.000Z</published>
    <updated>2026-10-18T00:00:00.000Z</updated>
    <summary></summary>
    <content type="html"><![CDATA[<p>Mermaid 是一种用文本描述图表的工具，写流程图、时序图、甘特图都不用拖拽画布，直接在 Markdown 里写代码块就行。Butterfly 主题支持通过插件渲染 Mermaid，配置起来也很简单。</p>
<hr />
<h3>一、安装插件</h3>
<p>在博客根目录执行：</p>
<pre><code>npm install --save hexo-filter-mermaid-diagrams
</code></pre>
<p>这个插件负责把文章里的 Mermaid 代码块识别出来并交给前端渲染。</p>
<hr />
<h3>二、配置主题</h3>
<p>打开主题目录下的 <code>themes/butterfly/_config.yml</code>(或博客根目录下的<code>_config.butterfly.yml</code>)，找到（或添加）<code>mermaid</code> 配置：</p>
<pre><code># Mermaid
# https://github.com/mermaid-js/mermaid
mermaid:
  enable: true
  # Write Mermaid diagrams using code blocks
  code_write: true
  # built-in themes: default / forest / dark / neutral
  theme:
    light: default
    dark: dark
  # Enable "Open in New Tab" button to view diagram in a separate window
  open_in_new_tab: true
  # Enable zoom and pan interactions on diagrams
  zoom_pan: true
</code></pre>
<p>几个关键项：</p>
<ul>
<li><code>enable</code>：开启 Mermaid 支持。</li>
<li><code>code_write</code>：允许用代码块写 Mermaid，<strong>必须为 <code>true</code></strong>，否则代码块不会转成图表。</li>
<li><code>theme.light</code> / <code>theme.dark</code>：分别对应浅色、深色模式下的图表主题。</li>
</ul>
<hr />
<h3>三、初始化脚本</h3>
<p>打开 <code>themes/butterfly/layout/includes/footer.pug</code>，在文件末尾添加下面的初始化脚本：</p>
<pre><code>if theme.mermaid &amp;&amp; theme.mermaid.enable
script(src=`https://unpkg.com/mermaid@11.5.0/dist/mermaid.min.js`)
script.
    if (window.mermaid) {
    mermaid.initialize({
        startOnLoad: true,
        theme: '#{theme.mermaid.theme || 'default'}',
        securityLevel: 'loose',
        flowchart: { useMaxWidth: true, htmlLabels: true }
    });
    }
</code></pre>
<p>这段脚本负责引入 <code>mermaid.js</code> 并完成初始化。其中 <code>startOnLoad: true</code> 会让页面加载时自动渲染所有图表，<code>securityLevel: 'loose'</code> 则允许 Mermaid 使用 HTML 标签做节点内容。</p>
<hr />
<h3>四、在文章中使用</h3>
<p>在 Markdown 里写一个 <code>mermaid</code> 代码块即可：</p>
<pre><code>```mermaid
flowchart LR
    A[安装插件] --&gt; B[配置主题]
    B --&gt; C[添加初始化脚本]
    C --&gt; D[文章里写代码块]
    D --&gt; E[重新生成]
    E --&gt; F[图表渲染成功]
```
</code></pre>
<p><strong>来看看效果</strong></p>
<pre><code>flowchart LR
    A[安装插件] --&gt; B[配置主题]
    B --&gt; C[添加初始化脚本]
    C --&gt; D[文章里写代码块]
    D --&gt; E[重新生成]
    E --&gt; F[图表渲染成功]
</code></pre>
<p>只要语言标注写成 <code>mermaid</code>，插件就会把它当成图表来处理。</p>
<hr />
<h3>五、重新生成</h3>
<p>改完配置后，重新生成一次站点：</p>
<pre><code>hexo clean &amp;&amp; hexo g &amp;&amp; hexo s
</code></pre>
<p>本地预览没问题，再推送到线上即可。</p>
]]></content>
    <author><name>Eira</name></author>
    <category term="教程"/>
  </entry>
  <entry>
    <title>Hexo Butterfly 配置 KaTex 公式</title>
    <link href="https://eirayun.top/posts/hexo-butterfly-%E9%85%8D%E7%BD%AE-katex-%E5%85%AC%E5%BC%8F/" rel="alternate" type="text/html"/>
    <id>https://eirayun.top/posts/hexo-butterfly-%E9%85%8D%E7%BD%AE-katex-%E5%85%AC%E5%BC%8F/</id>
    <published>2026-06-18T00:00:00.000Z</published>
    <updated>2026-06-18T00:00:00.000Z</updated>
    <summary></summary>
    <content type="html"><![CDATA[<p>对于使用 Hexo 搭建博客的朋友来说，Butterfly 主题内置了对 MathJax 和 KaTeX 的支持。考虑到 KaTeX 具有<strong>渲染速度快、样式轻量</strong>的优势，本文将以 Butterfly 主题为例，详细介绍如何配置并启用 KaTeX 数学公式渲染引擎</p>
<h2>配置主题文件</h2>
<p>首先，我们需要在 Butterfly 主题的配置文件中指定使用 KaTeX</p>
<p>打开主题目录下的 <code>_config.yml</code> 文件，找到 <code>math</code> 配置项，按照以下方式进行修改：</p>
<pre><code># --------------------------------------
# Math
# --------------------------------------
math:
  # 选择使用的渲染引擎，这里填写 katex
  use: katex
  
  # 全局加载设置
  # 设置为 true 表示在每个页面都加载渲染脚本，无需在文章 Front-matter 中单独声明
  per_page: true
  
  # KaTeX 专属配置
  katex:
    # 启用复制公式功能
    copy_tex: true
    # 隐藏滚动条（可选）
    hide_scrollbal: true
</code></pre>
<h2>安装依赖插件</h2>
<p>这一步是关键。Butterfly 默认可能使用的是 <code>marked</code> 渲染器，我们需要将其替换为兼容性更好的 <code>markdown-it</code>，并安装 KaTeX 相关插件</p>
<p>请在博客根目录的终端中依次执行以下命令：</p>
<pre><code># 1. 卸载默认的 marked 渲染器
npm un hexo-renderer-marked --save

# 2. 安装 markdown-it 作为基础 Markdown 解析器
npm install hexo-renderer-markdown-it --save

# 3. 安装 KaTeX 核心库及 markdown-it 插件
npm install katex @renbaoshuo/markdown-it-katex --save
</code></pre>
<h2>配置站点文件</h2>
<p>仅安装插件还不够，还需要告诉 Hexo 去使用它。打开博客<strong>根目录</strong>（而非主题目录）的 <code>_config.yml</code> 文件，在末尾添加或修改 <code>markdown</code> 配置：</p>
<pre><code>markdown:
  plugins:
    - '@renbaoshuo/markdown-it-katex'
</code></pre>
<h2>重启服务器</h2>
<p>重新启动Hexo服务器，查看公式是否正常渲染：</p>
<pre><code>hexo clean &amp;&amp; hexo s
</code></pre>
<h2>编写与测试公式</h2>
<p>在撰写文章时，您可以使用以下语法插入公式：</p>
<ul>
<li><strong>行内公式：</strong> 使用 <code>$...$</code> 包裹，例如 <code>$E=mc^2$</code>。</li>
<li><strong>独立公式：</strong> 使用 <code>$$...$$</code> 包裹。</li>
</ul>
<h3>示例代码：</h3>
<pre><code>$$
S_n = \sum_{i=1}^{n} \frac{1}{i}
$$
</code></pre>
<h3>渲染效果：</h3>
<p>$$
S_n = \sum_{i=1}^{n} \frac{1}{i}
$$</p>
<h2>🌟 优势总结</h2>
<p><strong>KaTeX 相比 MathJax 的优势：</strong></p>
<ul>
<li>渲染速度更快，提升用户体验</li>
<li>文件体积更小，减少页面加载时间</li>
<li>样式更简洁，视觉效果更佳</li>
<li>支持公式复制功能</li>
</ul>
]]></content>
    <author><name>Eira</name></author>
    <category term="教程"/>
  </entry>
  <entry>
    <title>Hexo Butterfly 自定义侧边栏卡片隐藏指南</title>
    <link href="https://eirayun.top/posts/hexo-butterfly-%E8%87%AA%E5%AE%9A%E4%B9%89%E4%BE%A7%E8%BE%B9%E6%A0%8F%E5%8D%A1%E7%89%87%E9%9A%90%E8%97%8F%E6%8C%87%E5%8D%97/" rel="alternate" type="text/html"/>
    <id>https://eirayun.top/posts/hexo-butterfly-%E8%87%AA%E5%AE%9A%E4%B9%89%E4%BE%A7%E8%BE%B9%E6%A0%8F%E5%8D%A1%E7%89%87%E9%9A%90%E8%97%8F%E6%8C%87%E5%8D%97/</id>
    <published>2026-06-16T00:00:00.000Z</published>
    <updated>2026-06-16T00:00:00.000Z</updated>
    <summary></summary>
    <content type="html"><![CDATA[<p>Hexo <strong>Butterfly</strong> 主题的侧边栏（Aside）默认会显示博主信息、最新文章、分类等全量卡片。但在“分类”或“标签”等特定页面，继续显示对应卡片会造成信息冗余。本文介绍一种<strong>无痛扩展方案</strong>：无需修改主题源码，利用 Hexo 过滤器脚本在编译时将 CSS 动态注入 HTML，实现通过页面 <code>Front-matter</code> 配置自由隐藏指定侧边栏卡片</p>
<h2>💡 核心原理</h2>
<p>Hexo 提供了 <code>after_render:html</code> 过滤器，允许在 HTML 渲染完成后、写入文件前对其内容进行修改。本方案通过脚本检测页面 <code>Front-matter</code> 中是否包含 <code>hide_cards</code> 字段。若存在，则生成 <code>display: none !important;</code> 的 CSS 规则，并将其精确注入到页面 <code>#body-wrap</code> 容器的起始位置，从而利用样式覆盖实现卡片隐藏</p>
<h2>🛠️ 操作步骤</h2>
<h3>1. 创建 Hexo 脚本</h3>
<p>在你的 Hexo 博客 <strong>根目录</strong>（注意不是 <code>themes/butterfly</code> 目录）下，找到或创建 <code>scripts</code> 文件夹。在该文件夹内新建一个名为 <code>custom_sidebar.js</code> 的文件</p>
<p>文件路径应为：<code>/scripts/custom_sidebar.js</code></p>
<h3>2. 编写注入逻辑</h3>
<p>打开 custom_sidebar.js，将以下代码复制并粘贴到该文件中：</p>
<pre><code>/**
 * Hexo 自定义侧边栏卡片隐藏脚本
 * 适用于 Butterfly 主题
 */
hexo.extend.filter.register('after_render:html', function(str, data) {
    // 检查当前页面数据是否存在 hide_cards 字段且为数组
    if (data &amp;&amp; data.page &amp;&amp; data.page.hide_cards &amp;&amp; Array.isArray(data.page.hide_cards)) {
        let cssRules = '';

        // 遍历需要隐藏的卡片列表
        data.page.hide_cards.forEach(card =&gt; {
            // 构建 CSS 选择器规则，强制隐藏对应 ID 的元素
            cssRules += `#body-wrap #aside-content .card-${card} { display: none !important; }\n`;
        });

        // 将 CSS 规则包裹在 style 标签中
        const styleTag = `&lt;style type="text/css" class="custom-pjax-sidebar"&gt;\n${cssRules}&lt;/style&gt;`;

        // 将生成的样式注入到 body-wrap div 之后
        return str.replace(/(&lt;div[^&gt;]*id=["']body-wrap["'][^&gt;]*&gt;)/i, '$1\n' + styleTag);
    }
    // 如果不需要隐藏，返回原始字符串
    return str;
});

</code></pre>
<h3>3. 在页面中应用配置</h3>
<p>现在，你可以在任意想要自定义侧边栏的 Markdown 文件（<code>.md</code>）的 <strong>Front-matter</strong>（头部元数据区域）中使用 <code>hide_cards</code> 字段，并在下方列出你想隐藏的卡片类型名称</p>
<p><strong>示例代码：</strong></p>
<pre><code>---
title: 我的工具箱
date: 2026-06-16 15:00:00
type: "tool"
# 在此处添加隐藏配置
hide_cards:
  - announcement      # 隐藏公告
  - recent-post       # 隐藏最新文章
  - categories        # 隐藏分类
  - tags              # 隐藏标签
  - webinfo           # 隐藏网站资讯
---
这里是正文内容...
</code></pre>
<h2>📋 参数配置速查表</h2>
<p>在页面顶部的 <code>Front-matter</code> 中，通过 <code>hide_cards</code> 数组填入以下对应的参数，即可隐藏指定的侧边栏卡片：</p>
<table>
<thead>
<tr>
<th>参数名称</th>
<th>隐藏卡片类型</th>
<th>对应的 CSS 选择器</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>author</code></td>
<td>博主信息</td>
<td><code>#body-wrap #aside-content .card-author</code></td>
</tr>
<tr>
<td><code>announcement</code></td>
<td>网站公告</td>
<td><code>#body-wrap #aside-content .card-announcement</code></td>
</tr>
<tr>
<td><code>recent-post</code></td>
<td>最新文章</td>
<td><code>#body-wrap #aside-content .card-recent-post</code></td>
</tr>
<tr>
<td><code>categories</code></td>
<td>文章分类</td>
<td><code>#body-wrap #aside-content .card-categories</code></td>
</tr>
<tr>
<td><code>tags</code></td>
<td>文章标签</td>
<td><code>#body-wrap #aside-content .card-tags</code></td>
</tr>
<tr>
<td><code>archives</code></td>
<td>文章归档</td>
<td><code>#body-wrap #aside-content .card-archives</code></td>
</tr>
<tr>
<td><code>webinfo</code></td>
<td>网站资讯</td>
<td><code>#body-wrap #aside-content .card-webinfo</code></td>
</tr>
</tbody>
</table>
<h2>✨ 效果验证与部署</h2>
<p>完成上述脚本创建和页面配置后，你需要在 Hexo 博客根目录下执行以下命令，清理旧的缓存并重新编译生成静态文件：</p>
<pre><code># 清理缓存并重新生成、启动本地服务
hexo clean &amp;&amp; hexo g &amp;&amp; hexo s
</code></pre>
]]></content>
    <author><name>Eira</name></author>
    <category term="教程"/>
  </entry>
  <entry>
    <title>Hexo 添加独立网页</title>
    <link href="https://eirayun.top/posts/hexo-%E6%B7%BB%E5%8A%A0%E7%8B%AC%E7%AB%8B%E7%BD%91%E9%A1%B5/" rel="alternate" type="text/html"/>
    <id>https://eirayun.top/posts/hexo-%E6%B7%BB%E5%8A%A0%E7%8B%AC%E7%AB%8B%E7%BD%91%E9%A1%B5/</id>
    <published>2026-06-01T00:00:00.000Z</published>
    <updated>2026-06-01T00:00:00.000Z</updated>
    <summary></summary>
    <content type="html"><![CDATA[<p>Hexo 默认使用主题渲染页面，但嵌入作品集、特效展示等独立网页时，易引发样式冲突。本文将介绍如何通过配置，让 Hexo 在生成静态文件时直接复制这些文件，跳过主题渲染，从而实现页面的完全独立</p>
<h2>💡 核心原理：跳过渲染</h2>
<p>Hexo 提供了一个非常实用的配置项 <code>skip_render</code>。当我们在配置文件中指定了该路径后，Hexo 在执行 <code>hexo generate</code> 命令时，会跳过对这些文件的 Markdown 解析和主题模板渲染，直接将它们原封不动地复制到 <code>public</code> 文件夹中</p>
<h2>🛠️ 详细操作步骤</h2>
<h3>第一步：创建文件夹并放入源码</h3>
<ol>
<li>打开你的 Hexo 博客根目录，进入 <code>source</code> 文件夹。</li>
<li>新建一个文件夹用于存放你的独立网页。<strong>强烈建议使用全小写英文命名</strong>（例如 <code>demo</code>、<code>portfolio</code>），避免在部署到 GitHub Pages 等服务器时因大小写敏感问题导致 404 错误。</li>
<li>将你的独立网页源码放入该文件夹中。通常你需要包含一个 <code>index.html</code> 文件，以及配套的 CSS、JS 和 Images 文件夹。</li>
</ol>
<p>最终的目录结构应该类似这样：</p>
<pre><code>source/
└── demo/
    ├── index.html
    ├── css/
    │   └── style.css
    └── js/
        └── main.js
</code></pre>
<h3>第二步：配置跳过渲染</h3>
<ol>
<li>回到 Hexo 博客根目录，找到并打开站点配置文件 <code>_config.yml</code>。</li>
<li>找到 <code>skip_render</code> 配置项（如果没有，可以手动添加）。</li>
<li>根据你的需求配置路径。推荐使用数组格式，方便后续添加多个独立页面：</li>
</ol>
<pre><code># 跳过渲染配置
skip_render:
  - "demo/**"      # 跳过 demo 文件夹下的所有文件及子文件夹
</code></pre>
<p><strong>路径匹配规则说明：</strong></p>
<ul>
<li><code>demo/*</code> ：仅跳过 <code>demo</code> 文件夹下的第一层文件，不包含子文件夹内的文件。</li>
<li><code>demo/**</code> ：跳过 <code>demo</code> 文件夹下的所有文件，<strong>包括所有子文件夹及其内部文件</strong>（最常用）。</li>
<li><code>demo/*.html</code> ：仅跳过 <code>demo</code> 文件夹下的 <code>.html</code> 文件。</li>
</ul>
<h3>第三步：检查并修正资源路径</h3>
<p>这是最容易出错的一步！因为跳过了渲染，Hexo 不会帮你处理 CSS 和 JS 的路径。你需要打开 <code>index.html</code>，检查资源引用的路径是否为相对路径。</p>
<p><strong>错误示范（绝对路径）：</strong></p>
<pre><code>&lt;link rel="stylesheet" href="/css/style.css"&gt;
</code></pre>
<p><strong>正确示范（相对路径）：</strong></p>
<pre><code>&lt;link rel="stylesheet" href="css/style.css"&gt;
</code></pre>
<h3>第四步：本地测试与部署</h3>
<p>配置完成后，务必按照以下标准流程进行测试：</p>
<pre><code># 1. 清理缓存（非常重要，防止旧缓存导致页面不更新）
hexo clean

# 2. 生成静态文件
hexo generate

# 3. 启动本地服务器预览
hexo server
</code></pre>
<p>在浏览器中访问 <code>http://localhost:4000/demo/</code>，确认页面样式正常、JS 交互无误后，再执行 <code>hexo deploy</code> 部署到远程服务器。</p>
<h2>✨ 进阶：将独立网页添加到导航菜单</h2>
<p>如果你希望访客能通过博客的导航栏直接进入这个独立页面，你需要修改<strong>主题配置文件</strong>（例如 Butterfly 主题的 <code>_config.butterfly.yml</code>）。</p>
<p>在 <code>menu</code> 菜单配置下添加：</p>
<pre><code>menu:
  首页: / || fas fa-home
  归档: /archives/ || fas fa-archive
  作品集: /demo/ || fas fa-code  # 添加这一行，路径对应 source 下的文件夹名
</code></pre>
<h2>📋 总结</h2>
<blockquote>
<p>通过 <code>skip_render</code> 配置，我们可以非常灵活地在 Hexo 博客中嵌入任何自定义的静态网页。这种方法既保留了 Hexo 博客的完整性，又赋予了开发者极大的自由度。下次当你有了炫酷的前端小项目，不妨用这个方法把它挂到博客上吧！</p>
</blockquote>
]]></content>
    <author><name>Eira</name></author>
    <category term="教程"/>
  </entry>
  <entry>
    <title>Hexo个人网站搭建教程</title>
    <link href="https://eirayun.top/posts/hexo%E5%AE%89%E8%A3%85%E6%95%99%E7%A8%8B/" rel="alternate" type="text/html"/>
    <id>https://eirayun.top/posts/hexo%E5%AE%89%E8%A3%85%E6%95%99%E7%A8%8B/</id>
    <published>2026-05-31T00:00:00.000Z</published>
    <updated>2026-05-31T00:00:00.000Z</updated>
    <summary></summary>
    <content type="html"><![CDATA[<h1>Hexo 个人网站搭建教程</h1>
<h2>一、Hexo简介</h2>
<p>Hexo 是一个快速、简洁且高效的静态博客框架，基于 Node.js 开发。通过 Markdown 编写文章，Hexo 可以快速生成静态网页，并部署到 GitHub Pages、Vercel、Netlify 等平台。</p>
<h3>Hexo特点</h3>
<ul>
<li>简单易用</li>
<li>支持 Markdown</li>
<li>丰富的主题生态</li>
<li>快速生成静态页面</li>
<li>免费部署</li>
</ul>
<hr />
<h1>二、环境准备</h1>
<p>在安装 Hexo 前，需要先安装以下软件：</p>
<h2>1. Node.js</h2>
<p>下载地址：</p>
<p>https://nodejs.org</p>
<p>验证安装：</p>
<pre><code>node -v
npm -v
</code></pre>
<p>示例输出：</p>
<pre><code>v22.0.0
10.5.1
</code></pre>
<hr />
<h2>2. Git</h2>
<p>下载地址：</p>
<p>https://git-scm.com</p>
<p>验证安装：</p>
<pre><code>git --version
</code></pre>
<p>示例：</p>
<pre><code>git version 2.48.1
</code></pre>
<hr />
<h1>三、安装Hexo</h1>
<p>全局安装 Hexo CLI：</p>
<pre><code>npm install -g hexo-cli
</code></pre>
<p>验证安装：</p>
<pre><code>hexo -v
</code></pre>
<p>出现版本信息即表示安装成功。</p>
<hr />
<h1>四、创建博客项目</h1>
<p>创建博客目录：</p>
<pre><code>hexo init my-blog
</code></pre>
<p>进入项目目录：</p>
<pre><code>cd my-blog
</code></pre>
<p>安装依赖：</p>
<pre><code>npm install
</code></pre>
<hr />
<h1>五、项目目录结构</h1>
<p>初始化完成后，目录结构如下：</p>
<pre><code>my-blog
├── _config.yml
├── package.json
├── scaffolds
├── source
│   └── _posts
├── themes
└── public
</code></pre>
<p>目录说明：</p>
<table>
<thead>
<tr>
<th>目录</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td>source</td>
<td>网站源文件</td>
</tr>
<tr>
<td>source/_posts</td>
<td>博客文章</td>
</tr>
<tr>
<td>themes</td>
<td>主题目录</td>
</tr>
<tr>
<td>public</td>
<td>生成后的静态文件</td>
</tr>
<tr>
<td>_config.yml</td>
<td>网站配置文件</td>
</tr>
</tbody>
</table>
<hr />
<h1>六、配置博客信息</h1>
<p>编辑根目录下的 <code>_config.yml</code>：</p>
<pre><code>title: QA Mo Blog
subtitle: 技术分享与生活记录
description: 我的个人博客
author: QA Mo
language: zh-CN
timezone: Asia/Shanghai
</code></pre>
<p>常用配置：</p>
<pre><code>url: https://yourname.github.io

permalink: :year/:month/:day/:title/

theme: landscape
</code></pre>
<hr />
<h1>七、创建第一篇文章</h1>
<p>创建文章：</p>
<pre><code>hexo new "我的第一篇博客"
</code></pre>
<p>生成文件：</p>
<pre><code>source/_posts/我的第一篇博客.md
</code></pre>
<p>编辑内容：</p>
<pre><code>---
title: 我的第一篇博客
date: 2026-05-31 10:00:00
tags:
- Hexo
- Blog
categories:
- 技术
---

欢迎来到我的博客！

这是使用 Hexo 编写的第一篇文章。
</code></pre>
<hr />
<h1>八、本地预览</h1>
<p>启动本地服务器：</p>
<pre><code>hexo server
</code></pre>
<p>或简写：</p>
<pre><code>hexo s
</code></pre>
<p>浏览器访问：</p>
<pre><code>http://localhost:4000
</code></pre>
<p>修改文章后刷新页面即可查看效果。</p>
<hr />
<h1>九、更换主题</h1>
<p>以 Next 主题为例。</p>
<h2>下载主题</h2>
<p>进入 themes 目录：</p>
<pre><code>cd themes
</code></pre>
<p>下载主题：</p>
<pre><code>git clone https://github.com/next-theme/hexo-theme-next.git next
</code></pre>
<hr />
<h2>修改配置</h2>
<p>编辑根目录 <code>_config.yml</code>：</p>
<pre><code>theme: next
</code></pre>
<hr />
<h2>更新依赖</h2>
<p>返回博客目录：</p>
<pre><code>npm install
</code></pre>
<p>启动测试：</p>
<pre><code>hexo clean
hexo g
hexo s
</code></pre>
<hr />
<h1>十、部署到GitHub Pages</h1>
<h2>创建仓库</h2>
<p>登录 GitHub。</p>
<p>创建仓库：</p>
<pre><code>用户名.github.io
</code></pre>
<p>例如：</p>
<pre><code>qamo.github.io
</code></pre>
<hr />
<h2>安装部署插件</h2>
<pre><code>npm install hexo-deployer-git --save
</code></pre>
<hr />
<h2>配置部署</h2>
<p>修改 <code>_config.yml</code>：</p>
<pre><code>deploy:
  type: git
  repo: https://github.com/用户名/用户名.github.io.git
  branch: main
</code></pre>
<p>例如：</p>
<pre><code>deploy:
  type: git
  repo: https://github.com/qamo/qamo.github.io.git
  branch: main
</code></pre>
<hr />
<h2>开始部署</h2>
<p>清理缓存：</p>
<pre><code>hexo clean
</code></pre>
<p>生成静态文件：</p>
<pre><code>hexo generate
</code></pre>
<p>部署：</p>
<pre><code>hexo deploy
</code></pre>
<p>简写命令：</p>
<pre><code>hexo clean &amp;&amp; hexo g &amp;&amp; hexo d
</code></pre>
<hr />
<h1>十一、绑定自定义域名</h1>
<p>在仓库 Settings → Pages 中配置：</p>
<pre><code>Custom Domain
</code></pre>
<p>输入：</p>
<pre><code>blog.example.com
</code></pre>
<p>在 DNS 服务商添加：</p>
<pre><code>Type: CNAME

Host: blog

Value: 用户名.github.io
</code></pre>
<hr />
<h1>十二、常用命令</h1>
<h2>新建文章</h2>
<pre><code>hexo new "文章标题"
</code></pre>
<h2>新建页面</h2>
<pre><code>hexo new page about
</code></pre>
<h2>清理缓存</h2>
<pre><code>hexo clean
</code></pre>
<h2>生成静态页面</h2>
<pre><code>hexo generate
</code></pre>
<h2>本地运行</h2>
<pre><code>hexo server
</code></pre>
<h2>部署网站</h2>
<pre><code>hexo deploy
</code></pre>
<hr />
<h1>十三、推荐插件</h1>
<h2>搜索功能</h2>
<pre><code>npm install hexo-generator-searchdb
</code></pre>
<hr />
<h2>RSS订阅</h2>
<pre><code>npm install hexo-generator-feed
</code></pre>
<hr />
<h2>网站地图</h2>
<pre><code>npm install hexo-generator-sitemap
</code></pre>
<hr />
<h2>SEO优化</h2>
<pre><code>npm install hexo-autonofollow
</code></pre>
<hr />
<h1>十四、自动部署GitHub Actions</h1>
<p>创建文件：</p>
<pre><code>.github/workflows/deploy.yml
</code></pre>
<p>内容如下：</p>
<pre><code>name: Deploy Hexo

on:
  push:
    branches:
      - main

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
    - name: Checkout
      uses: actions/checkout@v4

    - name: Setup Node.js
      uses: actions/setup-node@v4
      with:
        node-version: 22

    - name: Install Dependencies
      run: npm install

    - name: Generate
      run: npx hexo generate

    - name: Deploy
      uses: peaceiris/actions-gh-pages@v4
      with:
        github_token: ${{ secrets.GITHUB_TOKEN }}
        publish_dir: ./public
</code></pre>
<p>以后只需：</p>
<pre><code>git push
</code></pre>
<p>即可自动部署。</p>
<hr />
<h1>十五、总结</h1>
<p>Hexo 搭建流程如下：</p>
<pre><code>flowchart TD
    A[安装 Node.js] --&gt; B[安装 Git]
    B --&gt; C[安装 Hexo]
    C --&gt; D[初始化博客]
    D --&gt; E[配置网站信息]
    E --&gt; F[安装并配置主题]
    F --&gt; G[编写 Markdown 文章]
    G --&gt; H[本地预览测试]
    H --&gt; I[生成静态文件]
    I --&gt; J[部署到 GitHub Pages]
    J --&gt; K[绑定自定义域名]
    K --&gt; L[配置自动化部署]
    L --&gt; M[博客正式上线]
</code></pre>
<p>至此，一个完整的 Hexo 个人博客网站已经搭建完成。</p>
<p>建议后续学习：</p>
<ul>
<li>Markdown 写作</li>
<li>Next 主题配置</li>
<li>GitHub Actions 自动部署</li>
<li>评论系统（Giscus、Waline）</li>
<li>SEO优化</li>
<li>CDN加速</li>
<li>网站统计分析</li>
</ul>
]]></content>
    <author><name>Eira</name></author>
    <category term="教程"/>
  </entry>
</feed>
