<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="zh-CN">
  <title>墨安槿幻的幻想之境</title>
  <subtitle>墨安槿幻的个人博客。记录日常、幻想、角色与建站手记，一个 00 后上班族的自留地。</subtitle>
  <link href="https://moanjinhuan.top/atom.xml" rel="self"/>
  <link href="https://moanjinhuan.top/"/>
  <id>https://moanjinhuan.top/</id>
  <updated>2026-09-21T15:35:41.000Z</updated>
  <author><name>墨安槿幻</name></author>
  <entry>
    <title>搭建页面“骨架”（引入 layout.ejs）以及让页面漂亮起来（加入 css）</title>
    <link href="https://moanjinhuan.top/2026/09/21/four/"/>
    <id>https://moanjinhuan.top/2026/09/21/four/</id>
    <published>2026-09-21T15:35:41.000Z</published>
    <updated>2026-09-21T15:35:41.000Z</updated>
    <category term="建站手记"/>
    <content type="html"><![CDATA[<h2 id="🏗️-第一步：搭建页面“骨架”（引入-layout-ejs）"><a href="#🏗️-第一步：搭建页面“骨架”（引入-layout-ejs）" class="headerlink" title="🏗️ 第一步：搭建页面“骨架”（引入 layout.ejs）"></a>🏗️ 第一步：搭建页面“骨架”（引入 layout.ejs）</h2><p>现在的 index.ejs 既充当了网页外壳，又写了文章列表，这很乱。标准做法是把“外壳”独立出来。</p>
<span id="more"></span>

<h3 id="1-在-themes-my-theme-layout-文件夹里，新建一个文件，叫-layout-ejs。"><a href="#1-在-themes-my-theme-layout-文件夹里，新建一个文件，叫-layout-ejs。" class="headerlink" title="1. 在 themes&#x2F;my-theme&#x2F;layout&#x2F; 文件夹里，新建一个文件，叫 layout.ejs。"></a>1. 在 themes&#x2F;my-theme&#x2F;layout&#x2F; 文件夹里，新建一个文件，叫 layout.ejs。</h3><h3 id="2-把下面这段通用骨架代码复制进去（注意-这一行，这是核心）："><a href="#2-把下面这段通用骨架代码复制进去（注意-这一行，这是核心）：" class="headerlink" title="2. 把下面这段通用骨架代码复制进去（注意 &lt;%- body %&gt; 这一行，这是核心）："></a>2. 把下面这段通用骨架代码复制进去（注意 &lt;%- body %&gt; 这一行，这是核心）：</h3><figure class="highlight html"><table><tr><td class="code"><pre><span class="line"><span class="meta">&lt;!DOCTYPE <span class="keyword">html</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">html</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">head</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">meta</span> <span class="attr">charset</span>=<span class="string">&quot;utf-8&quot;</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">title</span>&gt;</span>&lt;%= config.title %&gt;<span class="tag">&lt;/<span class="name">title</span>&gt;</span></span><br><span class="line">  <span class="comment">&lt;!-- 引入刚刚写好的 CSS 样式文件，注意路径开头是斜杠 --&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">link</span> <span class="attr">rel</span>=<span class="string">&quot;stylesheet&quot;</span> <span class="attr">href</span>=<span class="string">&quot;/css/style.css&quot;</span>&gt;</span> </span><br><span class="line"><span class="tag">&lt;/<span class="name">head</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">body</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">header</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">h1</span>&gt;</span>欢迎来到我的博客<span class="tag">&lt;/<span class="name">h1</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">nav</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;<span class="name">a</span> <span class="attr">href</span>=<span class="string">&quot;/&quot;</span>&gt;</span>首页<span class="tag">&lt;/<span class="name">a</span>&gt;</span> | </span><br><span class="line">      <span class="tag">&lt;<span class="name">a</span> <span class="attr">href</span>=<span class="string">&quot;/archives&quot;</span>&gt;</span>归档<span class="tag">&lt;/<span class="name">a</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">nav</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;/<span class="name">header</span>&gt;</span></span><br><span class="line">  </span><br><span class="line">  <span class="comment">&lt;!-- 🌟 这里就是魔术发生的地方，其他页面的内容会被塞进这里 --&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">main</span> <span class="attr">class</span>=<span class="string">&quot;container&quot;</span>&gt;</span></span><br><span class="line">    &lt;%- body %&gt; </span><br><span class="line">  <span class="tag">&lt;/<span class="name">main</span>&gt;</span></span><br><span class="line">  </span><br><span class="line">  <span class="tag">&lt;<span class="name">footer</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">p</span>&gt;</span>© &lt;%= new Date().getFullYear() %&gt; 我的专属博客<span class="tag">&lt;/<span class="name">p</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;/<span class="name">footer</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">body</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">html</span>&gt;</span></span><br></pre></td></tr></table></figure>
<h3 id="3-然后，把你现在的-index-ejs-内容清空，只保留最核心的文章列表代码："><a href="#3-然后，把你现在的-index-ejs-内容清空，只保留最核心的文章列表代码：" class="headerlink" title="3. 然后，把你现在的 index.ejs 内容清空，只保留最核心的文章列表代码："></a>3. 然后，把你现在的 index.ejs 内容清空，只保留最核心的文章列表代码：</h3><figure class="highlight html"><table><tr><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">h2</span>&gt;</span>最新文章<span class="tag">&lt;/<span class="name">h2</span>&gt;</span></span><br><span class="line">&lt;% page.posts.each(function(post)&#123; %&gt;</span><br><span class="line">  <span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">&quot;post-item&quot;</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">h3</span>&gt;</span><span class="tag">&lt;<span class="name">a</span> <span class="attr">href</span>=<span class="string">&quot;&lt;%- url_for(post.path) %&gt;&quot;</span>&gt;</span>&lt;%= post.title %&gt;<span class="tag">&lt;/<span class="name">a</span>&gt;</span><span class="tag">&lt;/<span class="name">h3</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">p</span>&gt;</span>&lt;%= post.excerpt || &#x27;暂无摘要&#x27; %&gt;<span class="tag">&lt;/<span class="name">p</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br><span class="line">&lt;% &#125;); %&gt;</span><br></pre></td></tr></table></figure>
<p>保存后，在 Git Bash 里跑 hexo clean &amp;&amp; hexo s，刷新 localhost:4000。你会发现页面有了页头、导航栏和页脚，文章列表在中间。</p>
<h2 id="🎨-第二步：让页面漂亮起来（加上-CSS）"><a href="#🎨-第二步：让页面漂亮起来（加上-CSS）" class="headerlink" title="🎨 第二步：让页面漂亮起来（加上 CSS）"></a>🎨 第二步：让页面漂亮起来（加上 CSS）</h2><p>编写ing</p>
<hr>
<h3 id="更新时间：2026年9月20日"><a href="#更新时间：2026年9月20日" class="headerlink" title="更新时间：2026年9月20日"></a><em>更新时间：2026年9月20日</em></h3>]]></content>
  </entry>
  <entry>
    <title>页面出现乱码文字并解决</title>
    <link href="https://moanjinhuan.top/2026/09/20/three/"/>
    <id>https://moanjinhuan.top/2026/09/20/three/</id>
    <published>2026-09-20T01:51:11.000Z</published>
    <updated>2026-09-20T01:51:11.000Z</updated>
    <category term="建站手记"/>
    <content type="html"><![CDATA[<h2 id="🔍-为什么是乱码？"><a href="#🔍-为什么是乱码？" class="headerlink" title="🔍 为什么是乱码？"></a>🔍 为什么是乱码？</h2><p>用的是 Windows 自带的“记事本”编辑的 index.ejs。记事本默认会用“ANSI（中文系统下是 GBK）”格式保存文件。</p>
<p>但 Hexo 和浏览器默认用“UTF-8”格式去读。就像你用英语发音规则去读拼音，读出来肯定听不懂。</p>
<span id="more"></span>

<h2 id="🛠️-两步解决乱码："><a href="#🛠️-两步解决乱码：" class="headerlink" title="🛠️ 两步解决乱码："></a>🛠️ 两步解决乱码：</h2><h3 id="第一步：在-HTML-里加上-UTF-8-声明（必须做）"><a href="#第一步：在-HTML-里加上-UTF-8-声明（必须做）" class="headerlink" title="第一步：在 HTML 里加上 UTF-8 声明（必须做）"></a>第一步：在 HTML 里加上 UTF-8 声明（必须做）</h3><p>打开 themes&#x2F;my-theme&#x2F;layout&#x2F;index.ejs 文件，把 <head> 那一块改成这样：</p>
<figure class="highlight html"><table><tr><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">head</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">meta</span> <span class="attr">charset</span>=<span class="string">&quot;utf-8&quot;</span>&gt;</span>  <span class="comment">&lt;!-- 核心就加这一行 --&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">title</span>&gt;</span>&lt;%= config.title %&gt;<span class="tag">&lt;/<span class="name">title</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">head</span>&gt;</span></span><br></pre></td></tr></table></figure>
<h3 id="第二步：把文件重新保存为-UTF-8-格式（关键！）"><a href="#第二步：把文件重新保存为-UTF-8-格式（关键！）" class="headerlink" title="第二步：把文件重新保存为 UTF-8 格式（关键！）"></a>第二步：把文件重新保存为 UTF-8 格式（关键！）</h3><p>加了那行代码后，不要直接点保存，否则还是乱码。你需要另存为：</p>
<p>在记事本里点击左上角的 “文件” -&gt; “另存为”。</p>
<p>在底部找到 “编码” 下拉菜单。</p>
<p>把原来的 ANSI 改为 UTF-8 。</p>
<p>覆盖原来的 index.ejs 文件保存。</p>
<p>💡 强烈建议：为了以后不再受这个乱码的折磨，强烈建议你花 5 分钟下载一个免费工具 VS Code（code.visualstudio.com）。VS Code 默认就是 UTF-8，而且能高亮显示代码，你改完后以后基本不会再遇到编码问题了。</p>
<h2 id="🚀-第三步：重新预览"><a href="#🚀-第三步：重新预览" class="headerlink" title="🚀 第三步：重新预览"></a>🚀 第三步：重新预览</h2><p>去 Git Bash 里按 Ctrl + C 停掉之前的本地服务器，然后重新执行：</p>
<figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">hexo clean</span><br><span class="line">hexo s</span><br></pre></td></tr></table></figure>
<p>再去 <a href="http://localhost:4000/">http://localhost:4000</a> 看，乱码应该全消失，变成你写的中文了！</p>
<hr>
<h3 id="更新时间：2026年9月20日"><a href="#更新时间：2026年9月20日" class="headerlink" title="更新时间：2026年9月20日"></a><em>更新时间：2026年9月20日</em></h3>]]></content>
  </entry>
  <entry>
    <title>删除或换掉 reimu 主题</title>
    <link href="https://moanjinhuan.top/2026/09/19/two/"/>
    <id>https://moanjinhuan.top/2026/09/19/two/</id>
    <published>2026-09-19T00:39:09.000Z</published>
    <updated>2026-09-19T00:39:09.000Z</updated>
    <category term="建站手记"/>
    <content type="html"><![CDATA[<h2 id="🗑️第一步：如何卸载或换掉现在的-Reimu-主题？"><a href="#🗑️第一步：如何卸载或换掉现在的-Reimu-主题？" class="headerlink" title="🗑️第一步：如何卸载或换掉现在的 Reimu 主题？"></a>🗑️第一步：如何卸载或换掉现在的 Reimu 主题？</h2><p>千万不要直接去 themes 文件夹里把 reimu 文件夹删掉，如果 _config.yml 里还写着 theme: reimu，Hexo 启动会直接报错。</p>
<span id="more"></span>

<p>安全做法如下：</p>
<h3 id="1-先切换回默认主题："><a href="#1-先切换回默认主题：" class="headerlink" title="1. 先切换回默认主题："></a>1. 先切换回默认主题：</h3><p>打开根目录 _config.yml，把 theme: reimu 改成：</p>
<figure class="highlight yaml"><table><tr><td class="code"><pre><span class="line"><span class="attr">theme:</span> <span class="string">landscape</span></span><br></pre></td></tr></table></figure>

<p>landscape 是 Hexo 自带的默认主题，一直都在你的 themes 文件夹里）。</p>
<h3 id="2-清理缓存："><a href="#2-清理缓存：" class="headerlink" title="2. 清理缓存："></a>2. 清理缓存：</h3><p>在 Git Bash 里运行 hexo clean。</p>
<h3 id="3-测试是否成功："><a href="#3-测试是否成功：" class="headerlink" title="3. 测试是否成功："></a>3. 测试是否成功：</h3><p>运行 hexo s，打开 <a href="http://localhost:4000/">http://localhost:4000</a> ， 如果看到默认的蓝白主题，说明切换成功了。</p>
<h3 id="4-删除-Reimu（可选）："><a href="#4-删除-Reimu（可选）：" class="headerlink" title="4. 删除 Reimu（可选）："></a>4. 删除 Reimu（可选）：</h3><p>确认成功切换后，你可以去 themes 文件夹里，把 reimu 文件夹整个删掉。<br>（另外，你之前建在根目录的 _config.reimu.yml 也可以一并删掉）。</p>
<h2 id="🎨-第二步：如何从零开始做一个自己的主题？"><a href="#🎨-第二步：如何从零开始做一个自己的主题？" class="headerlink" title="🎨 第二步：如何从零开始做一个自己的主题？"></a>🎨 第二步：如何从零开始做一个自己的主题？</h2><p>做主题，其实就是把你设计的静态 HTML 网页，变成 Hexo 能读懂的“模板”。跟着我按以下步骤做：</p>
<h3 id="1-创建主题的“空壳”"><a href="#1-创建主题的“空壳”" class="headerlink" title="1. 创建主题的“空壳”"></a>1. 创建主题的“空壳”</h3><p>✅ 正确的“从零开始做主题”方法<br>第一步：手动创建主题文件夹<br>不需要敲任何命令，直接去你的电脑文件夹里，找到博客根目录下的 themes 文件夹。在里面，新建一个文件夹，名字就是你想要的主题名字，比如 my-theme。</p>
<p>第二步：让 Hexo 认识你的新主题<br>打开博客根目录的 _config.yml 文件，把 theme: 后面的名字，改成你刚创建的文件夹名字：theme: my-theme。</p>
<p>第三步：创建主题必备的“骨架”文件<br>进入 themes&#x2F;my-theme&#x2F; 文件夹，在里面新建以下内容：</p>
<ul>
<li><p>新建一个文件夹 layout</p>
</li>
<li><p>新建一个文件夹 source</p>
</li>
<li><p>新建一个文件 _config.yml（这个文件可以先空着）</p>
</li>
</ul>
<h3 id="2-认识三个核心文件"><a href="#2-认识三个核心文件" class="headerlink" title="2. 认识三个核心文件"></a>2. 认识三个核心文件</h3><p>去 themes&#x2F;my-theme 文件夹里，你会看到这些核心目录：</p>
<ul>
<li><p>_config.yml：你的主题的配置项（比如是否开启某功能）。</p>
</li>
<li><p>layout&#x2F;：这里放的是模板文件（.ejs 后缀）。</p>
</li>
<li><p>source&#x2F;：这里放你的 CSS、JS、图片。</p>
</li>
</ul>
<h3 id="3-🎨-下一步：怎么开始写你的第一个页面？"><a href="#3-🎨-下一步：怎么开始写你的第一个页面？" class="headerlink" title="3. 🎨 下一步：怎么开始写你的第一个页面？"></a>3. 🎨 下一步：怎么开始写你的第一个页面？</h3><p>刚才创建的 layout 文件夹就是用来放模板文件的地方。你需要用记事本或 VS Code 在里面新建一个文件，命名为 index.ejs，然后把下面这段代码复制进去：</p>
<figure class="highlight html"><table><tr><td class="code"><pre><span class="line"><span class="meta">&lt;!DOCTYPE <span class="keyword">html</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">html</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">head</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">title</span>&gt;</span>&lt;%= config.title %&gt;<span class="tag">&lt;/<span class="name">title</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">head</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">body</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">h1</span>&gt;</span>这是我亲手做的主题！<span class="tag">&lt;/<span class="name">h1</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">p</span>&gt;</span>网站标题是：&lt;%= config.title %&gt;<span class="tag">&lt;/<span class="name">p</span>&gt;</span></span><br><span class="line">  &lt;% page.posts.each(function(post)&#123; %&gt;</span><br><span class="line">    <span class="tag">&lt;<span class="name">div</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;<span class="name">h2</span>&gt;</span><span class="tag">&lt;<span class="name">a</span> <span class="attr">href</span>=<span class="string">&quot;&lt;%- url_for(post.path) %&gt;&quot;</span>&gt;</span>&lt;%= post.title %&gt;<span class="tag">&lt;/<span class="name">a</span>&gt;</span><span class="tag">&lt;/<span class="name">h2</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br><span class="line">  &lt;% &#125;); %&gt;</span><br><span class="line"><span class="tag">&lt;/<span class="name">body</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">html</span>&gt;</span></span><br></pre></td></tr></table></figure>

<h3 id="4-开启你的主题"><a href="#4-开启你的主题" class="headerlink" title="4. 开启你的主题"></a>4. 开启你的主题</h3><p>去根目录 _config.yml，把 theme: landscape 改成 theme: my-theme。<br>在 Git Bash 里执行：</p>
<figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">hexo clean</span><br><span class="line">hexo s</span><br></pre></td></tr></table></figure>
<p>打开 localhost:4000，你就能看到你刚亲手搭出来的主题（虽然可能非常简陋，但那是你写的！）。</p>
<hr>
<h3 id="更新时间：2026年9月19日"><a href="#更新时间：2026年9月19日" class="headerlink" title="更新时间：2026年9月19日"></a><em>更新时间：2026年9月19日</em></h3>]]></content>
  </entry>
  <entry>
    <title>🎉 零基础小白从零搭建 Hexo 博客踩坑全记录（附常用指令小抄）</title>
    <link href="https://moanjinhuan.top/2026/09/10/First/"/>
    <id>https://moanjinhuan.top/2026/09/10/First/</id>
    <published>2026-09-10T06:24:10.000Z</published>
    <updated>2026-09-10T06:24:10.000Z</updated>
    <category term="建站手记"/>
    <content type="html"><![CDATA[<h2 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h2><blockquote>
<h4 id="作为一个完全零基础的小白，从最初不知道命令行是什么，到最后成功把博客上线、换上漂亮的Reimu主题、改好头像，一路踩坑一路填，终于拥有了自己的网站：https-moanjinhuan-top。"><a href="#作为一个完全零基础的小白，从最初不知道命令行是什么，到最后成功把博客上线、换上漂亮的Reimu主题、改好头像，一路踩坑一路填，终于拥有了自己的网站：https-moanjinhuan-top。" class="headerlink" title="作为一个完全零基础的小白，从最初不知道命令行是什么，到最后成功把博客上线、换上漂亮的Reimu主题、改好头像，一路踩坑一路填，终于拥有了自己的网站：https://moanjinhuan.top。"></a>作为一个完全零基础的小白，从最初不知道命令行是什么，到最后成功把博客上线、换上漂亮的Reimu主题、改好头像，一路踩坑一路填，终于拥有了自己的网站：<a href="https://moanjinhuan.top./">https://moanjinhuan.top。</a></h4><h4 id="这篇文章记录了我整个搭建过程、遇到的报错以及解决办法，希望帮到同样零基础的你！"><a href="#这篇文章记录了我整个搭建过程、遇到的报错以及解决办法，希望帮到同样零基础的你！" class="headerlink" title="这篇文章记录了我整个搭建过程、遇到的报错以及解决办法，希望帮到同样零基础的你！"></a>这篇文章记录了我整个搭建过程、遇到的报错以及解决办法，希望帮到同样零基础的你！</h4></blockquote>
<span id="more"></span>

<hr>
<h2 id="🛠️-第一阶段：环境准备"><a href="#🛠️-第一阶段：环境准备" class="headerlink" title="🛠️ 第一阶段：环境准备"></a>🛠️ 第一阶段：环境准备</h2><h2 id="1-注册-GitHub-账号"><a href="#1-注册-GitHub-账号" class="headerlink" title="1. 注册 GitHub 账号"></a>1. 注册 GitHub 账号</h2><blockquote>
<h4 id="访问-https-github-com-，点击-Sign-up-注册。记住你的用户名，这是你博客网址的一部分。"><a href="#访问-https-github-com-，点击-Sign-up-注册。记住你的用户名，这是你博客网址的一部分。" class="headerlink" title="访问 https://github.com/，点击 Sign up 注册。记住你的用户名，这是你博客网址的一部分。"></a>访问 <a href="https://github.com/%EF%BC%8C%E7%82%B9%E5%87%BB">https://github.com/，点击</a> Sign up 注册。记住你的用户名，这是你博客网址的一部分。</h4></blockquote>
<h2 id="2-安装-Git-和-Node-js"><a href="#2-安装-Git-和-Node-js" class="headerlink" title="2. 安装 Git 和 Node.js"></a>2. 安装 Git 和 Node.js</h2><blockquote>
<h4 id="下载安装-Git-时，一定要注意这三个选项："><a href="#下载安装-Git-时，一定要注意这三个选项：" class="headerlink" title="下载安装 Git 时，一定要注意这三个选项："></a>下载安装 Git 时，一定要注意这三个选项：</h4><blockquote>
<ul>
<li>默认编辑器：选 VS Code 或 Notepad。</li>
<li>PATH 环境变量：选 Git from the command line and also from 3rd-party software（第二项）。</li>
<li>换行符转换：保持默认第一项即可。</li>
</ul>
</blockquote>
</blockquote>
<h2 id="3-安装-Hexo"><a href="#3-安装-Hexo" class="headerlink" title="3. 安装 Hexo"></a>3. 安装 Hexo</h2><blockquote>
<p>❌ 遇到的坑： 错误地打开了 Node.js 的快捷方式，在里面输入 npm i -g hexo-cli，结果报错 npm should be run outside of the Node.js REPL…。</p>
<p>✅ 解决办法： 退出 Node.js 环境（按 Ctrl + C 或 Ctrl + D），打开 Git Bash（在桌面右键选择 Git Bash Here）。在 Git Bash 中输入：</p>
</blockquote>
<figure class="highlight plaintext"><table><tr><td class="code"><pre><span class="line">&#123;</span><br><span class="line">npm i -g hexo-cli</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<hr>
<p>🏗️ 第二阶段：初始化博客和部署到 GitHub</p>
<h2 id="1-初始化博客"><a href="#1-初始化博客" class="headerlink" title="1. 初始化博客"></a>1. 初始化博客</h2><h2 id="我在-Moanjinhuan-目录下直接执行了："><a href="#我在-Moanjinhuan-目录下直接执行了：" class="headerlink" title="我在 ~&#x2F;Moanjinhuan 目录下直接执行了："></a>我在 ~&#x2F;Moanjinhuan 目录下直接执行了：</h2><figure class="highlight plaintext"><figcaption><span>bash</span></figcaption><table><tr><td class="code"><pre><span class="line">&#123;hexo init</span><br><span class="line">npm install</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>注意：并没有单独建 blog 文件夹，直接在 Moanjinhuan 文件夹里初始化了。</p>
<h2 id="2-创建-GitHub-Pages-仓库"><a href="#2-创建-GitHub-Pages-仓库" class="headerlink" title="2. 创建 GitHub Pages 仓库"></a>2. 创建 GitHub Pages 仓库</h2><blockquote>
<h4 id="在-GitHub-新建仓库，名字必须是-你的用户名-github-io（例如-Moanjinhuan-github-io），设为-Public。"><a href="#在-GitHub-新建仓库，名字必须是-你的用户名-github-io（例如-Moanjinhuan-github-io），设为-Public。" class="headerlink" title="在 GitHub 新建仓库，名字必须是 你的用户名.github.io（例如 Moanjinhuan.github.io），设为 Public。"></a>在 GitHub 新建仓库，名字必须是 你的用户名.github.io（例如 Moanjinhuan.github.io），设为 Public。</h4></blockquote>
<h2 id="3-连接本地与远程（九九八十一难开始）"><a href="#3-连接本地与远程（九九八十一难开始）" class="headerlink" title="3. 连接本地与远程（九九八十一难开始）"></a>3. 连接本地与远程（九九八十一难开始）</h2><blockquote>
<h4 id="❌-遇到的坑一（SSH-连接被拒）："><a href="#❌-遇到的坑一（SSH-连接被拒）：" class="headerlink" title="❌ 遇到的坑一（SSH 连接被拒）："></a>❌ 遇到的坑一（SSH 连接被拒）：</h4><p>使用 git clone <a href="mailto:&#x67;&#x69;&#116;&#64;&#x67;&#x69;&#116;&#104;&#117;&#98;&#x2e;&#99;&#x6f;&#109;">git@github.com</a>:… 报错 Connection refused。<br>✅ 解决办法： 改用 HTTPS 协议。</p>
</blockquote>
<figure class="highlight plaintext"><table><tr><td class="code"><pre><span class="line">git clone https://github.com/Moanjinhuan/Moanjinhuan.github.io.git</span><br></pre></td></tr></table></figure>

<blockquote>
<h4 id="❌-遇到的坑二（Git-身份未知）："><a href="#❌-遇到的坑二（Git-身份未知）：" class="headerlink" title="❌ 遇到的坑二（Git 身份未知）："></a>❌ 遇到的坑二（Git 身份未知）：</h4><p>执行 hexo deploy 报错 Author identity unknown。<br>✅ 解决办法： 在 Git Bash 中告诉 Git 我是谁：</p>
</blockquote>
<figure class="highlight plaintext"><table><tr><td class="code"><pre><span class="line">git config --global user.name &quot;Moanjinhuan&quot;</span><br><span class="line">git config --global user.email &quot;你的GitHub邮箱&quot;</span><br></pre></td></tr></table></figure>

<blockquote>
<h4 id="❌-遇到的坑三（授权卡住）："><a href="#❌-遇到的坑三（授权卡住）：" class="headerlink" title="❌ 遇到的坑三（授权卡住）："></a>❌ 遇到的坑三（授权卡住）：</h4><p>弹窗要求登录，浏览器授权卡死。<br>✅ 解决办法： 选择浏览器授权（Sign in with your browser）或直接使用 GitHub Token。去 GitHub 的 Settings -&gt; Developer settings -&gt; Personal access tokens 生成一个 Token（勾选 repo 权限），粘贴到密码框即可。</p>
</blockquote>
<blockquote>
<h4 id="❌-遇到的坑四（Pages-设置无法保存）："><a href="#❌-遇到的坑四（Pages-设置无法保存）：" class="headerlink" title="❌ 遇到的坑四（Pages 设置无法保存）："></a>❌ 遇到的坑四（Pages 设置无法保存）：</h4><p>在 GitHub 仓库 Settings -&gt; Pages 里，选 main 分支后 Save 按钮点不了。<br>✅ 解决办法： 因为页面顶部提示“已从 main 分支构建”，说明已经配置好了，无需重复保存。</p>
</blockquote>
<h2 id="4-配置-Hexo-部署文件"><a href="#4-配置-Hexo-部署文件" class="headerlink" title="4. 配置 Hexo 部署文件"></a>4. 配置 Hexo 部署文件</h2><p>在根目录 _config.yml 底部修改：</p>
<figure class="highlight plaintext"><table><tr><td class="code"><pre><span class="line">deploy:</span><br><span class="line">  type: git</span><br><span class="line">  repo: https://github.com/Moanjinhuan/Moanjinhuan.github.io.git</span><br><span class="line">  branch: main</span><br></pre></td></tr></table></figure>

<h2 id="🎨-第三阶段：更换-Reimu-主题与个性化"><a href="#🎨-第三阶段：更换-Reimu-主题与个性化" class="headerlink" title="🎨 第三阶段：更换 Reimu 主题与个性化"></a>🎨 第三阶段：更换 Reimu 主题与个性化</h2><h4 id="1-下载主题"><a href="#1-下载主题" class="headerlink" title="1. 下载主题"></a>1. 下载主题</h4><p>在 ~&#x2F;Moanjinhuan 下执行：</p>
<figure class="highlight plaintext"><figcaption><span>bash</span></figcaption><table><tr><td class="code"><pre><span class="line">git clone https://github.com/D-Sketon/hexo-theme-reimu.git themes/reimu</span><br></pre></td></tr></table></figure>

<h4 id="2-启用主题并创建覆盖配置"><a href="#2-启用主题并创建覆盖配置" class="headerlink" title="2. 启用主题并创建覆盖配置"></a>2. 启用主题并创建覆盖配置</h4><p>将 _config.yml 中的 theme 改为 reimu。<br>为了以后更新方便，在根目录创建 _config.reimu.yml 文件，以后主题的配置都在这里改。</p>
<p>❌ 遇到的坑五（线上显示“xiba”，本地正常）：<br>改完配置部署后，线上一直显示我之前随便测试的“xiba”。<br>✅ 解决办法： 重新执行部署三连，并在浏览器按 Ctrl + F5 强制刷新，清除 GitHub 的顽固缓存。</p>
<figure class="highlight plaintext"><figcaption><span>bash</span></figcaption><table><tr><td class="code"><pre><span class="line">hexo clean &amp;&amp; hexo generate &amp;&amp; hexo deploy</span><br></pre></td></tr></table></figure>

<h4 id="3-修改网站标题和头像"><a href="#3-修改网站标题和头像" class="headerlink" title="3. 修改网站标题和头像"></a>3. 修改网站标题和头像</h4><p>修改标题：在 _config.reimu.yml 里找到 title:，修改冒号后面的文字（注意冒号后要有空格）。</p>
<p>修改头像：</p>
<p>把图片重命名为纯英文如 bayunzi.jpg。<br>把图片放到 Moanjinhuan&#x2F;source&#x2F;_data&#x2F;avatar&#x2F; 文件夹里。<br>在 _config.reimu.yml 中找到 avatar:，改成 avatar: “bayunzi.jpg”（千万不要加路径，只写文件名）。</p>
<h2 id="📝-第四阶段：日常维护与指令小抄"><a href="#📝-第四阶段：日常维护与指令小抄" class="headerlink" title="📝 第四阶段：日常维护与指令小抄"></a>📝 第四阶段：日常维护与指令小抄</h2><p>⭐ 日常写博客“三板斧”（最重要！）<br>以后每次写完文章，或者改完配置，只需要在 Git Bash 里依次输入下面这三行：</p>
<figure class="highlight plaintext"><figcaption><span>bash</span></figcaption><table><tr><td class="code"><pre><span class="line">hexo clean      # 清理旧缓存</span><br><span class="line">hexo generate   # 生成新网页 (可简写 hexo g)</span><br><span class="line">hexo deploy     # 推送到 GitHub (可简写 hexo d)</span><br></pre></td></tr></table></figure>

<h3 id="💡-懒人极致版（一行搞定）："><a href="#💡-懒人极致版（一行搞定）：" class="headerlink" title="💡 懒人极致版（一行搞定）："></a>💡 懒人极致版（一行搞定）：</h3><figure class="highlight plaintext"><figcaption><span>bash</span></figcaption><table><tr><td class="code"><pre><span class="line">hexo clean &amp;&amp; hexo generate &amp;&amp; hexo deploy</span><br></pre></td></tr></table></figure>

<h3 id="✍️-写新文章"><a href="#✍️-写新文章" class="headerlink" title="✍️ 写新文章"></a>✍️ 写新文章</h3><figure class="highlight plaintext"><figcaption><span>bash</span></figcaption><table><tr><td class="code"><pre><span class="line">hexo new post &quot;文章标题&quot;</span><br></pre></td></tr></table></figure>

<p>然后去 source&#x2F;_posts&#x2F; 文件夹里找那个 .md 文件写内容。</p>
<h3 id="🧭-迷路指南"><a href="#🧭-迷路指南" class="headerlink" title="🧭 迷路指南"></a>🧭 迷路指南</h3><ul>
<li>cd ~&#x2F;Moanjinhuan：回到你的博客目录（每次打开 Git Bash 的第一件事）。</li>
<li>cd ..：退回到上一级文件夹。</li>
<li>ls：看看当前文件夹里有什么。</li>
<li>pwd：看看我现在在哪个路径。</li>
</ul>
<h3 id="🚀-偷懒"><a href="#🚀-偷懒" class="headerlink" title="🚀 偷懒"></a>🚀 偷懒</h3><ul>
<li>按键盘上的 ↑（上箭头）：自动出现刚刚输入过的命令，不用手打！</li>
<li>按键盘上的 Tab 键：自动补全文件名或路径，防止拼错。</li>
</ul>
<h3 id="💡-避坑总结"><a href="#💡-避坑总结" class="headerlink" title="💡 避坑总结"></a>💡 避坑总结</h3><ol>
<li><p>所有命令都在 Git Bash 里敲，不要打开 Node.js 去敲！</p>
</li>
<li><p>改外观（头像、标题、颜色）都在 _config.reimu.yml 里改。</p>
</li>
<li><p>改了配置一定要重新执行部署三连，并且浏览器按 Ctrl + F5 强制刷新。</p>
</li>
<li><p>非常重要：定期备份你的本地 Moanjinhuan 文件夹，因为你的文章源码全在这里！</p>
</li>
</ol>
<p>希望这篇文章能记录下我今天的努力，也能帮助到未来的自己。博客已上线，接下来就是好好写文章啦！🎉</p>
<hr>
<p>编辑中，<strong>更新时间：2026年9月16日</strong></p>
]]></content>
  </entry>
</feed>
