<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <author>
    <name>BrightNewMoon</name>
  </author>
  <generator uri="https://hexo.io/">Hexo</generator>
  <id>https://brightnewmoon.top/</id>
  <link href="https://brightnewmoon.top/" rel="alternate"/>
  <link href="https://brightnewmoon.top/atom.xml" rel="self"/>
  <rights>All rights reserved 2026, BrightNewMoon</rights>
  <subtitle>探索技术，记录生活</subtitle>
  <title>BrightNewMoon</title>
  <updated>2026-05-29T18:12:34.994Z</updated>
  <entry>
    <author>
      <name>BrightNewMoon</name>
    </author>
    <category term="教程" scheme="https://brightnewmoon.top/categories/%E6%95%99%E7%A8%8B/"/>
    <category term="教程" scheme="https://brightnewmoon.top/tags/%E6%95%99%E7%A8%8B/"/>
    <category term="Hexo" scheme="https://brightnewmoon.top/tags/Hexo/"/>
    <category term="Fluid" scheme="https://brightnewmoon.top/tags/Fluid/"/>
    <category term="GitHub Pages" scheme="https://brightnewmoon.top/tags/GitHub-Pages/"/>
    <content>
      <![CDATA[<p>从零开始搭建一个漂亮的个人博客，其实没那么难。本教程面向零基础小白，每一步都有详细说明，跟着做就能上线。</p><h2 id="准备工作"><a href="#准备工作" class="headerlink" title="准备工作"></a>准备工作</h2><p>在开始之前，你需要准备好以下三样东西：</p><ul><li><strong>一台电脑</strong>（Windows &#x2F; macOS &#x2F; Linux 均可）</li><li><strong>一个 GitHub 账号</strong>（免费注册：<a href="https://github.com/">github.com</a>）</li><li><strong>一个文本编辑器</strong>（推荐 <a href="https://code.visualstudio.com/">VS Code</a>，免费好用）</li></ul><h3 id="1-安装-Node-js"><a href="#1-安装-Node-js" class="headerlink" title="1. 安装 Node.js"></a>1. 安装 Node.js</h3><p>Hexo 基于 Node.js 运行，所以第一步是安装 Node.js。</p><p>打开浏览器，访问 <a href="https://nodejs.org/">https://nodejs.org</a>，下载 <strong>LTS 版本</strong>（长期支持版，更稳定）。下载后双击安装包，一路点击 “Next” 完成安装。</p><blockquote><p><strong>LTS 是什么意思？</strong> Long Term Support，也就是这个版本经过了长期测试，稳定性最好。不要选最新版（Current），可能有不兼容的问题。</p></blockquote><p>安装完成后，验证是否安装成功。打开终端：</p><ul><li><strong>Windows</strong>：按 <code>Win + R</code>，输入 <code>cmd</code>，回车</li><li><strong>macOS</strong>：按 <code>Cmd + Space</code>，搜索 “终端”，回车</li></ul><p>在终端中输入以下命令，如果看到版本号就说明安装成功了：</p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><code class="hljs bash">node -v<br><span class="hljs-comment"># 应该输出类似 v20.x.x 的版本号</span><br><br>npm -v<br><span class="hljs-comment"># 应该输出类似 10.x.x 的版本号</span><br></code></pre></td></tr></table></figure><blockquote><p><strong>npm 是什么？</strong> 它是 Node.js 自带的包管理器。你可以把它理解为”应用商店”——通过它安装各种工具和插件，包括 Hexo。</p></blockquote><h3 id="2-安装-Git"><a href="#2-安装-Git" class="headerlink" title="2. 安装 Git"></a>2. 安装 Git</h3><p>Git 是版本控制工具，Hexo 通过 Git 把博客推送到 GitHub Pages。</p><p>访问 <a href="https://git-scm.com/downloads">https://git-scm.com/downloads</a>，下载对应操作系统的安装包，一路默认安装即可。</p><p>验证安装：</p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs bash">git --version<br><span class="hljs-comment"># 应该输出类似 git version 2.x.x</span><br></code></pre></td></tr></table></figure><p>安装完成后，还需要配置你的用户名和邮箱（替换成你自己的）：</p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs bash">git config --global user.name <span class="hljs-string">&quot;你的名字&quot;</span><br>git config --global user.email <span class="hljs-string">&quot;你的邮箱@example.com&quot;</span><br></code></pre></td></tr></table></figure><blockquote><p><strong>为什么要配置这个？</strong> 每次提交代码时，Git 都会记录是谁提交的，这个用户名和邮箱会显示在你的 GitHub 提交记录中。</p></blockquote><h3 id="3-注册-GitHub-账号"><a href="#3-注册-GitHub-账号" class="headerlink" title="3. 注册 GitHub 账号"></a>3. 注册 GitHub 账号</h3><p>如果你还没有 GitHub 账号，打开 <a href="https://github.com/">github.com</a>，点击右上角 “Sign up”，按提示注册。记住你的用户名，后面会用到。</p><hr><h2 id="创建博客项目"><a href="#创建博客项目" class="headerlink" title="创建博客项目"></a>创建博客项目</h2><h3 id="4-安装-Hexo-脚手架"><a href="#4-安装-Hexo-脚手架" class="headerlink" title="4. 安装 Hexo 脚手架"></a>4. 安装 Hexo 脚手架</h3><p>在终端中输入以下命令，全局安装 Hexo 命令行工具：</p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs bash">npm install -g hexo-cli<br></code></pre></td></tr></table></figure><p>这个命令会安装 <code>hexo</code> 命令到你的系统中。<code>-g</code> 表示全局安装，安装一次后可以在任何目录使用。</p><p>验证安装：</p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs bash">hexo version<br><span class="hljs-comment"># 应该输出 hexo-cli 和各项依赖的版本号</span><br></code></pre></td></tr></table></figure><h3 id="5-初始化博客"><a href="#5-初始化博客" class="headerlink" title="5. 初始化博客"></a>5. 初始化博客</h3><p>选择一个目录来存放你的博客。比如在桌面上创建一个 <code>blog</code> 文件夹：</p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><code class="hljs bash"><span class="hljs-comment"># 先切换到桌面</span><br><span class="hljs-built_in">cd</span> Desktop<br><br><span class="hljs-comment"># 初始化一个名为 blog 的 Hexo 项目</span><br>hexo init blog<br><br><span class="hljs-comment"># 进入项目目录</span><br><span class="hljs-built_in">cd</span> blog<br><br><span class="hljs-comment"># 安装依赖包</span><br>npm install<br></code></pre></td></tr></table></figure><blockquote><p><strong><code>hexo init blog</code> 做了什么？</strong> 它会自动下载 Hexo 的默认项目模板，包括基本的目录结构、默认主题（landscape）、一篇示例文章以及必要的配置文件。整个过程大约需要 1-2 分钟。</p></blockquote><h3 id="6-了解目录结构"><a href="#6-了解目录结构" class="headerlink" title="6. 了解目录结构"></a>6. 了解目录结构</h3><p>初始化完成后，你的 <code>blog</code> 文件夹结构如下：</p><figure class="highlight nix"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><code class="hljs nix">blog<span class="hljs-symbol">/</span><br>├── _config.yml          <span class="hljs-comment"># 网站配置文件（最重要）</span><br>├── package.json         <span class="hljs-comment"># 项目依赖信息</span><br>├── scaffolds<span class="hljs-symbol">/</span>           <span class="hljs-comment"># 文章模板</span><br>├── source<span class="hljs-symbol">/</span>              <span class="hljs-comment"># 你的文章和页面放这里</span><br>│   └── _posts<span class="hljs-symbol">/</span>          <span class="hljs-comment"># 所有博客文章（Markdown 文件）</span><br>├── themes<span class="hljs-symbol">/</span>              <span class="hljs-comment"># 主题文件夹</span><br>└── node_modules<span class="hljs-symbol">/</span>        <span class="hljs-comment"># 依赖包（不要手动修改）</span><br></code></pre></td></tr></table></figure><blockquote><p><strong>需要关注的只有两个地方：</strong> <code>_config.yml</code> 配置文件，和 <code>source/_posts/</code> 文章目录。其他目录一般不需要改动。</p></blockquote><h3 id="7-本地预览"><a href="#7-本地预览" class="headerlink" title="7. 本地预览"></a>7. 本地预览</h3><p>在项目目录下运行：</p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs bash">hexo server<br></code></pre></td></tr></table></figure><p>或者简写为：</p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs bash">hexo s<br></code></pre></td></tr></table></figure><p>打开浏览器，访问 <code>http://localhost:4000</code>，你应该能看到一个默认的博客页面。</p><blockquote><p><strong>提示：</strong> 按 <code>Ctrl + C</code> 可以停止本地服务器。每次修改配置或文章后，刷新浏览器即可看到变化（不需要重启服务器）。</p></blockquote><hr><h2 id="安装-Fluid-主题"><a href="#安装-Fluid-主题" class="headerlink" title="安装 Fluid 主题"></a>安装 Fluid 主题</h2><p>默认主题比较朴素。我们换成 Fluid，这是一款 Material Design 风格的高颜值主题。</p><h3 id="8-安装主题"><a href="#8-安装主题" class="headerlink" title="8. 安装主题"></a>8. 安装主题</h3><p>在博客项目目录下运行：</p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs bash">npm install hexo-theme-fluid --save<br></code></pre></td></tr></table></figure><p>这个命令会把 Fluid 主题下载到 <code>node_modules/hexo-theme-fluid/</code> 目录。</p><h3 id="9-启用主题"><a href="#9-启用主题" class="headerlink" title="9. 启用主题"></a>9. 启用主题</h3><p>用编辑器（VS Code）打开项目根目录下的 <code>_config.yml</code> 文件，找到 <code>theme</code> 字段，修改为：</p><figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs yaml"><span class="hljs-attr">theme:</span> <span class="hljs-string">fluid</span><br></code></pre></td></tr></table></figure><blockquote><p><strong>注意：</strong> <code>_config.yml</code> 文件中有很多配置项，不要被吓到。现在只需要关心 <code>theme</code> 这一个字段。</p></blockquote><h3 id="10-创建主题配置文件"><a href="#10-创建主题配置文件" class="headerlink" title="10. 创建主题配置文件"></a>10. 创建主题配置文件</h3><p>Fluid 主题提供了丰富的定制选项。我们需要把主题的默认配置文件复制到博客根目录：</p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs bash"><span class="hljs-comment"># 复制主题配置文件到博客根目录</span><br><span class="hljs-built_in">cp</span> node_modules/hexo-theme-fluid/_config.yml _config.fluid.yml<br></code></pre></td></tr></table></figure><blockquote><p><strong>macOS&#x2F;Linux 用户</strong> 用上面的命令。<br><strong>Windows 用户</strong> 如果 <code>cp</code> 命令无效，直接用文件管理器复制文件即可：进入 <code>node_modules/hexo-theme-fluid/</code> 目录，找到 <code>_config.yml</code>，复制到 <code>blog/</code> 根目录，重命名为 <code>_config.fluid.yml</code>。</p></blockquote><h3 id="11-基础主题配置"><a href="#11-基础主题配置" class="headerlink" title="11. 基础主题配置"></a>11. 基础主题配置</h3><p>打开 <code>_config.fluid.yml</code>，修改以下几项基本信息：</p><figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><code class="hljs yaml"><span class="hljs-comment"># 网站标题</span><br><span class="hljs-attr">navbar:</span><br>  <span class="hljs-attr">blog_title:</span> <span class="hljs-string">&quot;你的博客名称&quot;</span><br><br><span class="hljs-comment"># 首页大标题</span><br><span class="hljs-attr">banner:</span><br>  <span class="hljs-attr">title:</span> <span class="hljs-string">&quot;你的博客名称&quot;</span><br>  <span class="hljs-attr">subtitle:</span> <span class="hljs-string">&quot;一句个性签名&quot;</span><br><br><span class="hljs-comment"># 头像</span><br><span class="hljs-attr">about:</span><br>  <span class="hljs-attr">avatar:</span> <span class="hljs-string">/img/avatar.png</span><br>  <span class="hljs-attr">name:</span> <span class="hljs-string">&quot;你的名字&quot;</span><br>  <span class="hljs-attr">intro:</span> <span class="hljs-string">&quot;你的自我介绍&quot;</span><br></code></pre></td></tr></table></figure><blockquote><p><strong>配置优先级：</strong> <code>_config.fluid.yml</code> 的优先级高于主题自带的 <code>_config.yml</code>，所以你只需要在 <code>_config.fluid.yml</code> 中覆盖你想修改的部分即可。</p></blockquote><h3 id="12-放入头像"><a href="#12-放入头像" class="headerlink" title="12. 放入头像"></a>12. 放入头像</h3><p>找一张正方形的头像图片，重命名为 <code>avatar.png</code>，放入 <code>source/img/</code> 目录（如果没有 <code>img</code> 文件夹就新建一个）。</p><hr><h2 id="写第一篇文章"><a href="#写第一篇文章" class="headerlink" title="写第一篇文章"></a>写第一篇文章</h2><h3 id="13-创建文章"><a href="#13-创建文章" class="headerlink" title="13. 创建文章"></a>13. 创建文章</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs bash">hexo new <span class="hljs-string">&quot;我的第一篇文章&quot;</span><br></code></pre></td></tr></table></figure><p>这会在 <code>source/_posts/</code> 目录下生成一个 <code>我的第一篇文章.md</code> 文件。</p><blockquote><p><strong>命名建议：</strong> 文件名尽量用英文，Hexo 会自动处理中文标题。如果文件名是中文，生成的 URL 里会有长长的编码，不好看。</p></blockquote><h3 id="14-理解-Front-Matter"><a href="#14-理解-Front-Matter" class="headerlink" title="14. 理解 Front Matter"></a>14. 理解 Front Matter</h3><p>打开刚生成的文章文件，你会看到顶部的 <code>---</code> 包裹区域：</p><figure class="highlight markdown"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><code class="hljs markdown">---<br>title: 我的第一篇文章<br>date: 2026-05-30 12:00:00<br>tags: []<br><span class="hljs-section">categories: []</span><br><span class="hljs-section">---</span><br><br>这里是文章正文，支持 Markdown 语法。<br></code></pre></td></tr></table></figure><p>这个 <code>---</code> 包裹的区域叫做 <strong>Front Matter</strong>，用来定义文章的元信息：</p><table><thead><tr><th>字段</th><th>说明</th><th>示例</th></tr></thead><tbody><tr><td><code>title</code></td><td>文章标题</td><td><code>我的第一篇文章</code></td></tr><tr><td><code>date</code></td><td>创建时间</td><td><code>2026-05-30 12:00:00</code></td></tr><tr><td><code>tags</code></td><td>标签（可以有多个）</td><td><code>[前端, JavaScript]</code></td></tr><tr><td><code>categories</code></td><td>分类</td><td><code>技术</code></td></tr></tbody></table><blockquote><p><strong>tags 和 categories 的区别：</strong> 标签更细粒度，一篇文章可以有多个标签；分类更宏观，一篇通常只有一个分类。</p></blockquote><h3 id="15-写文章"><a href="#15-写文章" class="headerlink" title="15. 写文章"></a>15. 写文章</h3><p>在 <code>---</code> 下方用 Markdown 语法写正文。如果你还不太熟悉 Markdown，下面是最常用的语法速查：</p><figure class="highlight markdown"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br></pre></td><td class="code"><pre><code class="hljs markdown"><span class="hljs-section"># 一级标题</span><br><span class="hljs-section">## 二级标题</span><br><span class="hljs-section">### 三级标题</span><br><br><span class="hljs-strong">**粗体文字**</span><br><span class="hljs-emphasis">*斜体文字*</span><br><br><span class="hljs-bullet">-</span> 无序列表项 1<br><span class="hljs-bullet">-</span> 无序列表项 2<br><br><span class="hljs-bullet">1.</span> 有序列表项 1<br><span class="hljs-bullet">2.</span> 有序列表项 2<br><br>[<span class="hljs-string">链接文字</span>](<span class="hljs-link">https://example.com</span>)<br><br>![<span class="hljs-string">图片描述</span>](<span class="hljs-link">图片路径</span>)<br><br><span class="hljs-quote">&gt; 引用文字</span><br><br><span class="hljs-code">`行内代码`</span><br><br>​<span class="hljs-code">```bash</span><br><span class="hljs-code"># 代码块</span><br><span class="hljs-code">echo &quot;Hello World&quot;</span><br><span class="hljs-code">​```</span><br></code></pre></td></tr></table></figure><blockquote><p><strong>注意：</strong> 代码块的三个反引号在实际使用时前面不要有那个零宽空格（<code>&amp;#8203;</code>），这里加它是为了避免 Markdown 解析冲突。你直接打三个反引号即可。</p></blockquote><p>写完文章后，运行 <code>hexo s</code> 在本地预览效果。</p><hr><h2 id="部署到-GitHub-Pages"><a href="#部署到-GitHub-Pages" class="headerlink" title="部署到 GitHub Pages"></a>部署到 GitHub Pages</h2><p>现在你的博客在本地可以看了，接下来把它发布到互联网上。</p><h3 id="16-创建-GitHub-仓库"><a href="#16-创建-GitHub-仓库" class="headerlink" title="16. 创建 GitHub 仓库"></a>16. 创建 GitHub 仓库</h3><p>GitHub Pages 的仓库名有固定格式：**<code>你的用户名.github.io</code>**</p><p>比如你的 GitHub 用户名是 <code>zhangsan</code>，仓库名就是 <code>zhangsan.github.io</code>。</p><p>操作步骤：</p><ol><li>登录 GitHub</li><li>点击右上角 <code>+</code> → <code>New repository</code></li><li>Repository name 填写 <code>你的用户名.github.io</code></li><li>选择 <strong>Public</strong>（公开）</li><li><strong>不要勾选</strong> “Add a README file”（重要！）</li><li>点击 “Create repository”</li></ol><blockquote><p><strong>为什么仓库名必须这样？</strong> GitHub 规定，只有命名为 <code>用户名.github.io</code> 的仓库才会自动开启 GitHub Pages 功能。其他名字的仓库也可以开 Pages，但 URL 不同。</p></blockquote><h3 id="17-配置部署信息"><a href="#17-配置部署信息" class="headerlink" title="17. 配置部署信息"></a>17. 配置部署信息</h3><p>打开项目根目录的 <code>_config.yml</code>（注意不是 <code>_config.fluid.yml</code>），找到 <code>deploy</code> 部分，修改为：</p><figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><code class="hljs yaml"><span class="hljs-attr">deploy:</span><br>  <span class="hljs-attr">type:</span> <span class="hljs-string">git</span><br>  <span class="hljs-attr">repo:</span> <span class="hljs-string">https://github.com/你的用户名/你的用户名.github.io.git</span><br>  <span class="hljs-attr">branch:</span> <span class="hljs-string">gh-pages</span><br></code></pre></td></tr></table></figure><p>例如你的 GitHub 用户名是 <code>zhangsan</code>：</p><figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><code class="hljs yaml"><span class="hljs-attr">deploy:</span><br>  <span class="hljs-attr">type:</span> <span class="hljs-string">git</span><br>  <span class="hljs-attr">repo:</span> <span class="hljs-string">https://github.com/zhangsan/zhangsan.github.io.git</span><br>  <span class="hljs-attr">branch:</span> <span class="hljs-string">gh-pages</span><br></code></pre></td></tr></table></figure><blockquote><p><strong>branch: gh-pages 是什么意思？</strong> 部署的内容会被推送到仓库的 <code>gh-pages</code> 分支，而不是 <code>main</code> 分支。这样可以把源代码和生成的静态文件分开管理。</p></blockquote><h3 id="18-安装部署插件"><a href="#18-安装部署插件" class="headerlink" title="18. 安装部署插件"></a>18. 安装部署插件</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs bash">npm install hexo-deployer-git --save<br></code></pre></td></tr></table></figure><p>这个插件让 Hexo 能够自动把生成的静态文件推送到 GitHub。</p><h3 id="19-一键部署"><a href="#19-一键部署" class="headerlink" title="19. 一键部署"></a>19. 一键部署</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs bash">hexo clean &amp;&amp; hexo deploy<br></code></pre></td></tr></table></figure><p>这个命令做了三件事：</p><ol><li><code>hexo clean</code> — 清除之前生成的旧文件</li><li><code>hexo generate</code>（隐式）— 重新生成静态网站</li><li><code>hexo deploy</code> — 推送到 GitHub</li></ol><p>首次部署时会弹出 GitHub 登录窗口，授权即可。之后部署不需要重复登录。</p><blockquote><p><strong>部署失败？</strong> 如果遇到 <code>Permission denied</code> 错误，可能是 Git 认证没配置好。可以改用 SSH 方式：在 GitHub 设置中添加 SSH Key，然后把 repo 地址改为 <code>git@github.com:用户名/用户名.github.io.git</code>。</p></blockquote><h3 id="20-查看你的博客"><a href="#20-查看你的博客" class="headerlink" title="20. 查看你的博客"></a>20. 查看你的博客</h3><p>等待 1-2 分钟，打开浏览器访问 <code>https://你的用户名.github.io</code>，你应该就能看到自己的博客了！</p><p>如果看到 404 页面，去 GitHub 仓库的 <code>Settings → Pages</code>，确认 Source 选的是 <code>gh-pages</code> 分支。</p><hr><h2 id="绑定自定义域名"><a href="#绑定自定义域名" class="headerlink" title="绑定自定义域名"></a>绑定自定义域名</h2><p>使用 <code>用户名.github.io</code> 看起来不够专业。你可以买一个自己的域名，比如 <code>yourname.com</code>。</p><h3 id="21-购买域名"><a href="#21-购买域名" class="headerlink" title="21. 购买域名"></a>21. 购买域名</h3><p>推荐以下域名服务商（支持支付宝&#x2F;微信支付）：</p><ul><li><a href="https://www.namesilo.com/">NameSilo</a> — 价格实惠，送免费 WHOIS 隐私保护</li><li><a href="https://cloud.tencent.com/">腾讯云</a> — 国内用户方便</li><li><a href="https://wanwang.aliyun.com/">阿里云</a> — 国内用户方便</li></ul><p>一般 <code>.com</code> 域名首年约 50-80 元，<code>.top</code> 等域名更便宜，首年只需几块钱。</p><h3 id="22-配置-DNS"><a href="#22-配置-DNS" class="headerlink" title="22. 配置 DNS"></a>22. 配置 DNS</h3><p>在域名服务商的管理后台，添加以下 DNS 记录：</p><table><thead><tr><th>类型</th><th>主机记录</th><th>记录值</th></tr></thead><tbody><tr><td>CNAME</td><td>@</td><td>你的用户名.github.io</td></tr><tr><td>CNAME</td><td>www</td><td>你的用户名.github.io</td></tr></tbody></table><blockquote><p><strong>什么是 CNAME？</strong> 它相当于一个别名&#x2F;转发——告诉浏览器”当你访问 <code>yourname.com</code> 时，实际上是访问 <code>你的用户名.github.io</code>“。从用户的角度完全看不到后面那个地址。</p></blockquote><p>如果你用 Cloudflare 管理 DNS，添加 A 记录指向 GitHub Pages 的 IP 地址也可以：</p><figure class="highlight dns"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><code class="hljs dns"><span class="hljs-keyword">A</span>    @    <span class="hljs-number">185.199.108.153</span><br><span class="hljs-keyword">A</span>    @    <span class="hljs-number">185.199.109.153</span><br><span class="hljs-keyword">A</span>    @    <span class="hljs-number">185.199.110.153</span><br><span class="hljs-keyword">A</span>    @    <span class="hljs-number">185.199.111.153</span><br></code></pre></td></tr></table></figure><h3 id="23-创建-CNAME-文件"><a href="#23-创建-CNAME-文件" class="headerlink" title="23. 创建 CNAME 文件"></a>23. 创建 CNAME 文件</h3><p>在你的博客项目的 <code>source/</code> 目录下，新建一个名为 <code>CNAME</code> 的文件（没有扩展名）：</p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs bash"><span class="hljs-built_in">source</span>/<br>└── CNAME<br></code></pre></td></tr></table></figure><p>在文件中写入你的域名（不带 https:&#x2F;&#x2F;，不带路径）：</p><figure class="highlight coq"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs coq">brightnewmoon.<span class="hljs-built_in">top</span><br></code></pre></td></tr></table></figure><blockquote><p><strong>为什么要 CNAME 文件？</strong> 每次部署时，Hexo 会把这个文件也上传到服务器。GitHub 看到这个文件就知道”这个仓库绑定了这个域名”，从而正确处理访问请求。</p></blockquote><h3 id="24-GitHub-设置"><a href="#24-GitHub-设置" class="headerlink" title="24. GitHub 设置"></a>24. GitHub 设置</h3><p>进入你的 GitHub 仓库 → Settings → Pages，在 Custom domain 中填入你的域名，点击 Save。</p><p>GitHub 会自动检查 DNS 配置是否正确。如果显示 “DNS check successful”，说明配置成功。</p><h3 id="25-启用-HTTPS"><a href="#25-启用-HTTPS" class="headerlink" title="25. 启用 HTTPS"></a>25. 启用 HTTPS</h3><p>在同一个 Pages 设置页面，勾选 <strong>Enforce HTTPS</strong>。GitHub 会自动为你申请和续期免费的 Let’s Encrypt SSL 证书。这个功能在 DNS 配置生效后（通常需要几分钟到几小时）才能开启。</p><hr><h2 id="进阶美化"><a href="#进阶美化" class="headerlink" title="进阶美化"></a>进阶美化</h2><p>以下操作会让你的博客更上一层楼。</p><h3 id="26-开启暗色模式"><a href="#26-开启暗色模式" class="headerlink" title="26. 开启暗色模式"></a>26. 开启暗色模式</h3><p>在 <code>_config.fluid.yml</code> 中：</p><figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><code class="hljs yaml"><span class="hljs-attr">color_scheme:</span><br>  <span class="hljs-attr">enable:</span> <span class="hljs-literal">true</span><br>  <span class="hljs-comment"># 可选 auto / light / dark</span><br>  <span class="hljs-attr">default:</span> <span class="hljs-string">auto</span><br></code></pre></td></tr></table></figure><p><code>auto</code> 表示跟随用户系统的明暗设置自动切换。</p><h3 id="27-开启文章阅读进度条"><a href="#27-开启文章阅读进度条" class="headerlink" title="27. 开启文章阅读进度条"></a>27. 开启文章阅读进度条</h3><figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><code class="hljs yaml"><span class="hljs-attr">reading_progress:</span><br>  <span class="hljs-attr">enable:</span> <span class="hljs-literal">true</span><br>  <span class="hljs-attr">color:</span> <span class="hljs-string">&quot;#7c3aed&quot;</span><br>  <span class="hljs-attr">height:</span> <span class="hljs-string">3px</span><br></code></pre></td></tr></table></figure><h3 id="28-开启代码高亮和复制按钮"><a href="#28-开启代码高亮和复制按钮" class="headerlink" title="28. 开启代码高亮和复制按钮"></a>28. 开启代码高亮和复制按钮</h3><figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><code class="hljs yaml"><span class="hljs-attr">code:</span><br>  <span class="hljs-attr">copy_btn:</span> <span class="hljs-literal">true</span><br>  <span class="hljs-attr">language:</span> <span class="hljs-literal">true</span><br><br><span class="hljs-attr">highlight:</span><br>  <span class="hljs-attr">enable:</span> <span class="hljs-literal">true</span><br>  <span class="hljs-attr">line_number:</span> <span class="hljs-literal">true</span><br></code></pre></td></tr></table></figure><p>这样代码块右上角会有一个复制按钮，读者可以一键复制代码。</p><h3 id="29-添加友情链接页"><a href="#29-添加友情链接页" class="headerlink" title="29. 添加友情链接页"></a>29. 添加友情链接页</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs bash">hexo new page links<br></code></pre></td></tr></table></figure><p>编辑 <code>source/links/index.md</code>，添加：</p><figure class="highlight markdown"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><code class="hljs markdown">---<br>title: 友情链接<br>date: 2026-05-30<br><span class="hljs-section">type: links</span><br><span class="hljs-section">---</span><br><br>这里是我的朋友们。<br></code></pre></td></tr></table></figure><p>然后在 <code>_config.fluid.yml</code> 中配置友链数据：</p><figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><code class="hljs yaml"><span class="hljs-attr">links:</span><br>  <span class="hljs-attr">items:</span><br>    <span class="hljs-bullet">-</span> <span class="hljs-attr">title:</span> <span class="hljs-string">&quot;小明的主页&quot;</span><br>      <span class="hljs-attr">url:</span> <span class="hljs-string">&quot;https://xiaoming.com&quot;</span><br>      <span class="hljs-attr">intro:</span> <span class="hljs-string">&quot;一个有趣的博客&quot;</span><br>      <span class="hljs-attr">avatar:</span> <span class="hljs-string">&quot;https://xiaoming.com/avatar.png&quot;</span><br></code></pre></td></tr></table></figure><h3 id="30-添加评论系统（Giscus）"><a href="#30-添加评论系统（Giscus）" class="headerlink" title="30. 添加评论系统（Giscus）"></a>30. 添加评论系统（Giscus）</h3><p>Giscus 是一个基于 GitHub Discussions 的免费评论系统，无广告、不收集隐私。</p><p><strong>第一步：安装 Giscus GitHub App</strong></p><p>打开 <a href="https://github.com/apps/giscus">https://github.com/apps/giscus</a>，点击 Install，选择你的博客仓库。</p><p><strong>第二步：获取配置参数</strong></p><p>打开 <a href="https://giscus.app/zh-CN">https://giscus.app/zh-CN</a>，填写你的仓库名，按提示操作，最后会生成一段配置代码，从中可以提取：</p><ul><li><code>data-repo</code></li><li><code>data-repo-id</code></li><li><code>data-category</code></li><li><code>data-category-id</code></li></ul><p><strong>第三步：配置到 Fluid</strong></p><p>在 <code>_config.fluid.yml</code> 中：</p><figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><code class="hljs yaml"><span class="hljs-attr">comments:</span><br>  <span class="hljs-attr">enable:</span> <span class="hljs-literal">true</span><br>  <span class="hljs-attr">type:</span> <span class="hljs-string">giscus</span><br>  <span class="hljs-attr">giscus:</span><br>    <span class="hljs-attr">repo:</span> <span class="hljs-string">&quot;你的用户名/你的用户名.github.io&quot;</span><br>    <span class="hljs-attr">repo_id:</span> <span class="hljs-string">&quot;从 giscus.app 获取&quot;</span><br>    <span class="hljs-attr">category:</span> <span class="hljs-string">&quot;Announcements&quot;</span><br>    <span class="hljs-attr">category_id:</span> <span class="hljs-string">&quot;从 giscus.app 获取&quot;</span><br>    <span class="hljs-attr">lang:</span> <span class="hljs-string">&quot;zh-CN&quot;</span><br>    <span class="hljs-attr">mapping:</span> <span class="hljs-string">&quot;pathname&quot;</span><br></code></pre></td></tr></table></figure><p>配置完成后重新部署，每篇文章底部就会出现评论区。</p><h3 id="31-自定义-CSS"><a href="#31-自定义-CSS" class="headerlink" title="31. 自定义 CSS"></a>31. 自定义 CSS</h3><p>在 <code>source/css/</code> 目录下创建 <code>custom.css</code> 文件，然后在 <code>_config.fluid.yml</code> 中引用：</p><figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs yaml"><span class="hljs-attr">custom_css:</span> <span class="hljs-string">/css/custom.css</span><br></code></pre></td></tr></table></figure><p>你可以在这个文件中覆盖任何主题样式。比如修改主题色：</p><figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><code class="hljs css"><span class="hljs-selector-pseudo">:root</span> &#123;<br>  <span class="hljs-attr">--accent-color</span>: <span class="hljs-number">#7c3aed</span>;<br>&#125;<br><br><span class="hljs-selector-attr">[data-user-color-scheme=<span class="hljs-string">&#x27;dark&#x27;</span>]</span> &#123;<br>  <span class="hljs-attr">--accent-color</span>: <span class="hljs-number">#a78bfa</span>;<br>&#125;<br></code></pre></td></tr></table></figure><h3 id="32-添加网站图标"><a href="#32-添加网站图标" class="headerlink" title="32. 添加网站图标"></a>32. 添加网站图标</h3><p>准备一个 SVG 或 PNG 图标，放到 <code>source/img/favicon.svg</code>，然后在 <code>_config.fluid.yml</code> 中：</p><figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs yaml"><span class="hljs-attr">favicon:</span> <span class="hljs-string">/img/favicon.svg</span><br></code></pre></td></tr></table></figure><hr><h2 id="日常使用"><a href="#日常使用" class="headerlink" title="日常使用"></a>日常使用</h2><p>博客上线后，日常操作就三件事：</p><p><strong>写新文章：</strong></p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><code class="hljs bash">hexo new <span class="hljs-string">&quot;文章标题&quot;</span><br><span class="hljs-comment"># 编辑 source/_posts/文章标题.md</span><br>hexo s    <span class="hljs-comment"># 本地预览</span><br></code></pre></td></tr></table></figure><p><strong>部署发布：</strong></p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs bash">hexo clean &amp;&amp; hexo deploy<br></code></pre></td></tr></table></figure><p><strong>备份源代码：</strong><br>建议把整个博客项目的源代码也推到一个 GitHub 仓库（私人仓库即可），这样换电脑也能继续写博客。</p><hr><h2 id="常见问题"><a href="#常见问题" class="headerlink" title="常见问题"></a>常见问题</h2><p><strong>Q：部署后页面样式错乱？</strong></p><p>A：检查 <code>_config.yml</code> 中的 <code>url</code> 和 <code>root</code> 配置是否正确。如果是 <code>用户名.github.io</code> 仓库，<code>root</code> 应该是 <code>/</code>。</p><p><strong>Q：图片不显示？</strong></p><p>A：图片放在 <code>source/img/</code> 目录下，文章中引用时使用 <code>/img/图片名.png</code>（以 <code>/</code> 开头的绝对路径）。</p><p><strong>Q：修改配置后没有生效？</strong></p><p>A：执行 <code>hexo clean</code> 清除缓存，再重新生成。有些配置修改后本地预览不会马上生效。</p><p><strong>Q：中文文件名变成乱码 URL？</strong></p><p>A：这是 URL 编码。建议文章文件名用英文，中文标题在 Front Matter 的 <code>title</code> 字段中写。</p><p><strong>Q：怎么让百度收录我的博客？</strong></p><p>A：GitHub Pages 会屏蔽百度爬虫。可以考虑用国内 CDN 加速，或者使用双线部署（GitHub Pages + Gitee Pages &#x2F; 云服务器）。</p><hr><p>搭建博客只是一个开始，坚持写作才是最重要的。祝你博客之旅愉快！</p>]]>
    </content>
    <id>https://brightnewmoon.top/2026/05/30/hexo-fluid-blog-setup/</id>
    <link href="https://brightnewmoon.top/2026/05/30/hexo-fluid-blog-setup/"/>
    <published>2026-05-29T16:00:00.000Z</published>
    <summary>
      <![CDATA[<p>从零开始搭建一个漂亮的个人博客，其实没那么难。本教程面向零基础小白，每一步都有详细说明，跟着做就能上线。</p>
<h2 id="准备工作"><a href="#准备工作" class="headerlink" title="准备工作"></a>准备工作</h2><p>在开]]>
    </summary>
    <title>Hexo + Fluid 博客搭建全攻略</title>
    <updated>2026-05-29T18:12:34.994Z</updated>
  </entry>
  <entry>
    <author>
      <name>BrightNewMoon</name>
    </author>
    <category term="随笔" scheme="https://brightnewmoon.top/categories/%E9%9A%8F%E7%AC%94/"/>
    <category term="随笔" scheme="https://brightnewmoon.top/tags/%E9%9A%8F%E7%AC%94/"/>
    <content>
      <![CDATA[<p>历经一番折腾，我的个人博客终于搭建成功了！</p><h2 id="技术栈"><a href="#技术栈" class="headerlink" title="技术栈"></a>技术栈</h2><ul><li><strong>Hexo</strong> — 静态博客框架</li><li><strong>Fluid</strong> — 简洁优雅的主题</li><li><strong>GitHub Pages</strong> — 免费托管</li><li><strong>自定义域名</strong> — brightnewmoon.top</li></ul><h2 id="关于我"><a href="#关于我" class="headerlink" title="关于我"></a>关于我</h2><p>欢迎来到我的博客。这里会记录我的技术探索和生活感悟，希望你能在这里找到有趣的内容。</p><h2 id="后续计划"><a href="#后续计划" class="headerlink" title="后续计划"></a>后续计划</h2><p>持续学习，持续写作。Stay hungry, stay foolish.</p>]]>
    </content>
    <id>https://brightnewmoon.top/2026/05/29/hello-world/</id>
    <link href="https://brightnewmoon.top/2026/05/29/hello-world/"/>
    <published>2026-05-28T16:00:00.000Z</published>
    <summary>
      <![CDATA[<p>历经一番折腾，我的个人博客终于搭建成功了！</p>
<h2 id="技术栈"><a href="#技术栈" class="headerlink" title="技术栈"></a>技术栈</h2><ul>
<li><strong>Hexo</strong> — 静态博客框架<]]>
    </summary>
    <title>博客上线啦！</title>
    <updated>2026-05-29T18:05:41.108Z</updated>
  </entry>
</feed>
