atom.xml 42.3 KB
Newer Older
Alderaan's avatar
Alderaan 已提交
1 2 3 4 5 6 7 8
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title>Alderaan的博客</title>
  
  
  <link href="/atom.xml" rel="self"/>
  
  <link href="https://alderaan.xyz/"/>
Alderaan's avatar
Alderaan 已提交
9
  <updated>2020-05-07T06:18:27.046Z</updated>
Alderaan's avatar
Alderaan 已提交
10 11 12 13 14 15 16 17 18
  <id>https://alderaan.xyz/</id>
  
  <author>
    <name>Alderaan</name>
    
  </author>
  
  <generator uri="https://hexo.io/">Hexo</generator>
  
Alderaan's avatar
Alderaan 已提交
19
  <entry>
Alderaan's avatar
Alderaan 已提交
20
    <title>ssh -T git@github.com Connection reset by XXX port 22</title>
Alderaan's avatar
Alderaan 已提交
21 22 23
    <link href="https://alderaan.xyz/2020/05/07/ssh-to-git-github-com-connection-reset/"/>
    <id>https://alderaan.xyz/2020/05/07/ssh-to-git-github-com-connection-reset/</id>
    <published>2020-05-07T05:34:09.000Z</published>
Alderaan's avatar
Alderaan 已提交
24
    <updated>2020-05-07T06:18:27.046Z</updated>
Alderaan's avatar
Alderaan 已提交
25
    
Alderaan's avatar
Alderaan 已提交
26
    <content type="html"><![CDATA[<h2 id="概述"><a href="#概述" class="headerlink" title="概述"></a>概述</h2><p>​    今天在用<strong>Hexo</strong>发布博客文章时,遇到上传<strong>Github</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><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">Connection reset by 52.74.223.119</span><br><span class="line">fatal: Could not <span class="built_in">read</span> from remote repository.</span><br><span class="line"></span><br><span class="line">Please make sure you have the correct access rights</span><br><span class="line">and the repository exists.</span><br></pre></td></tr></table></figure><a id="more"></a><h2 id="问题发现"><a href="#问题发现" class="headerlink" title="问题发现"></a>问题发现</h2><p>​    由于已经在<code>Git bash</code>中配置过SSH免密访问,且已正常使用过也没有进行修改,所以排除SSH key配置问题。怀疑是无法连接到<code>github.com</code>,尝试执行<code>ssh -T git@github.com</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><span class="line">$ ssh -T git@github.com</span><br><span class="line">Connection reset by 52.74.223.119 port 22</span><br></pre></td></tr></table></figure><p>​    竟然真的无法SSH连接到github.com???增加<code>-v</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><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></pre></td><td class="code"><pre><span class="line">$ ssh -T -v git@github.com</span><br><span class="line">OpenSSH_8.0p1, OpenSSL 1.1.1c  28 May 2019</span><br><span class="line">debug1: Reading configuration data /c/Users/Alder/.ssh/config</span><br><span class="line">debug1: Reading configuration data /etc/ssh/ssh_config</span><br><span class="line">debug1: Connecting to github.com [52.74.223.119] port 22.</span><br><span class="line">debug1: Connection established.</span><br><span class="line">debug1: identity file /c/Users/Alder/.ssh/id_rsa <span class="built_in">type</span> 0</span><br><span class="line">debug1: identity file /c/Users/Alder/.ssh/id_rsa-cert <span class="built_in">type</span> -1</span><br><span class="line">debug1: identity file /c/Users/Alder/.ssh/id_dsa <span class="built_in">type</span> -1</span><br><span class="line">debug1: identity file /c/Users/Alder/.ssh/id_dsa-cert <span class="built_in">type</span> -1</span><br><span class="line">debug1: identity file /c/Users/Alder/.ssh/id_ecdsa <span class="built_in">type</span> -1</span><br><span class="line">debug1: identity file /c/Users/Alder/.ssh/id_ecdsa-cert <span class="built_in">type</span> -1</span><br><span class="line">debug1: identity file /c/Users/Alder/.ssh/id_ed25519 <span class="built_in">type</span> -1</span><br><span class="line">debug1: identity file /c/Users/Alder/.ssh/id_ed25519-cert <span class="built_in">type</span> -1</span><br><span class="line">debug1: identity file /c/Users/Alder/.ssh/id_xmss <span class="built_in">type</span> -1</span><br><span class="line">debug1: identity file /c/Users/Alder/.ssh/id_xmss-cert <span class="built_in">type</span> -1</span><br><span class="line">debug1: Local version string SSH-2.0-OpenSSH_8.0</span><br><span class="line">debug1: Remote protocol version 2.0, remote software version babeld-d45c1532</span><br><span class="line">debug1: no match: babeld-d45c1532</span><br><span class="line">debug1: Authenticating to github.com:22 as <span class="string">'git'</span></span><br><span class="line">debug1: SSH2_MSG_KEXINIT sent</span><br><span class="line">Connection reset by 52.74.223.119 port 22</span><br></pre></td></tr></table></figure><h2 id="问题解决"><a href="#问题解决" class="headerlink" title="问题解决"></a>问题解决</h2><p>​    在Windows系统下,打开控制面板-&gt;系统和安全-&gt;Windows Defender 防火墙-&gt;高级设置,选择入站规则,点击新建规则,选择端口,在特定本地端口写入22,连续选择下一步三次,输入一个名称(随意命名规则),点击完成,然后再执行命令得到如下格式结果:</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><span class="line">$ ssh -T git@github.com</span><br><span class="line">Hi XXX! You<span class="string">'ve successfully authenticated, but GitHub does not provide shell access.</span></span><br></pre></td></tr></table></figure><p>​    再尝试发布<strong>Hexo</strong>博客到<strong>Github</strong>就可以正常上传了…暂时不知道这其中的原理,即使将刚添加的规则删除了,再打开新的<code>Git bash</code>窗口也不会出现Connection reset错误了。。。</p>]]></content>
Alderaan's avatar
Alderaan 已提交
27 28 29
    
    <summary type="html">
    
Alderaan's avatar
Alderaan 已提交
30 31
      &lt;h2 id=&quot;概述&quot;&gt;&lt;a href=&quot;#概述&quot; class=&quot;headerlink&quot; title=&quot;概述&quot;&gt;&lt;/a&gt;概述&lt;/h2&gt;&lt;p&gt;​    今天在用&lt;strong&gt;Hexo&lt;/strong&gt;发布博客文章时,遇到上传&lt;strong&gt;Github&lt;/strong&gt;失败问题,主要提示为&lt;/p&gt;
&lt;figure class=&quot;highlight bash&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;gutter&quot;&gt;&lt;pre&gt;&lt;span class=&quot;line&quot;&gt;1&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;line&quot;&gt;2&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;line&quot;&gt;3&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;line&quot;&gt;4&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;line&quot;&gt;5&lt;/span&gt;&lt;br&gt;&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;line&quot;&gt;Connection reset by 52.74.223.119&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;line&quot;&gt;fatal: Could not &lt;span class=&quot;built_in&quot;&gt;read&lt;/span&gt; from remote repository.&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;line&quot;&gt;Please make sure you have the correct access rights&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;line&quot;&gt;and the repository exists.&lt;/span&gt;&lt;br&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/figure&gt;
Alderaan's avatar
Alderaan 已提交
32
    
Alderaan's avatar
Alderaan 已提交
33 34 35
    </summary>
    
    
Alderaan's avatar
Alderaan 已提交
36 37 38 39 40 41
      <category term="Github" scheme="https://alderaan.xyz/categories/Github/"/>
    
    
      <category term="Github" scheme="https://alderaan.xyz/tags/Github/"/>
    
      <category term="SSH" scheme="https://alderaan.xyz/tags/SSH/"/>
Alderaan's avatar
Alderaan 已提交
42 43 44
    
  </entry>
  
Alderaan's avatar
Alderaan 已提交
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
  <entry>
    <title>Hexo博客Next主题美化</title>
    <link href="https://alderaan.xyz/2020/05/06/hexo-config/"/>
    <id>https://alderaan.xyz/2020/05/06/hexo-config/</id>
    <published>2020-05-06T07:01:22.000Z</published>
    <updated>2020-05-07T03:44:34.073Z</updated>
    
    <content type="html"><![CDATA[<p>​    本文主要说明在<strong>Hexo</strong>博客<strong>nexT</strong>主题下如何进行美化,具体对应效果可通过本博客页面进行查看。</p><ul><li>Hexo version: 4.2.0</li><li>nexT version:7.8.0</li></ul><a id="more"></a><hr><h2 id="更改nexT主题为中文"><a href="#更改nexT主题为中文" class="headerlink" title="更改nexT主题为中文"></a>更改nexT主题为中文</h2><p>​    在<strong>站点配置文件</strong>中的<code>Site</code>配置进行如下修改:</p><figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="attr">language:</span> <span class="string">zh-CN</span> <span class="comment"># 简体中文</span></span><br></pre></td></tr></table></figure><hr><h2 id="更改头像"><a href="#更改头像" class="headerlink" title="更改头像"></a>更改头像</h2><p>​    将头像图片放在<code>/blog/themes/next/source/images/</code>下,然后在<strong>主题配置文件</strong>下搜索<code>avatar.gif</code>,修改为要替换的头像图片名称。</p><figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># Replace the default image and set the url here.</span></span><br><span class="line"><span class="attr">url:</span> <span class="string">/images/avatar.jpg</span> <span class="comment"># 头像图片名称 这里我的图片成名为avatar.jpg</span></span><br></pre></td></tr></table></figure><hr><h2 id="更改头像显示框为圆形"><a href="#更改头像显示框为圆形" class="headerlink" title="更改头像显示框为圆形"></a>更改头像显示框为圆形</h2><p>​    在<code>/blog/themes/next/source/css/_common/outline/sidebar</code>文件夹下编辑<code>sidebar-author.styl</code>文件,做出如下修改:</p><figure class="highlight stylus"><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></pre></td><td class="code"><pre><span class="line"><span class="selector-class">.site-author-image</span> &#123;</span><br><span class="line">  <span class="attribute">border</span>: <span class="variable">$site</span>-author-image-border-width solid <span class="variable">$site</span>-author-image-border-color;</span><br><span class="line">  <span class="attribute">display</span>: block;</span><br><span class="line">  <span class="attribute">margin</span>: <span class="number">0</span> auto;</span><br><span class="line">  <span class="attribute">max-width</span>: <span class="variable">$site</span>-author-image-width;</span><br><span class="line">  <span class="attribute">padding</span>: <span class="number">2px</span>;</span><br><span class="line">  </span><br><span class="line">  <span class="comment">/* 头像圆形 */</span></span><br><span class="line">  border-radius: 50%; # 新增</span><br><span class="line">  transition: 2s all; # 新增</span><br><span class="line"></span><br><span class="line">  <span class="keyword">if</span> (hexo-config(<span class="string">'avatar.rounded'</span>)) &#123;</span><br><span class="line">    <span class="attribute">border-radius</span>: <span class="number">50%</span>;</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure><hr><h2 id="更改博客标题和作者名称"><a href="#更改博客标题和作者名称" class="headerlink" title="更改博客标题和作者名称"></a>更改博客标题和作者名称</h2><p>​    在<strong>站点配置文件</strong>中的<code>Site</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></pre></td><td class="code"><pre><span class="line"><span class="comment"># Site</span></span><br><span class="line"><span class="attr">title:</span> <span class="string">Alderaan的博客</span> <span class="comment"># 博客名称</span></span><br><span class="line"><span class="attr">subtitle:</span> <span class="string">''</span></span><br><span class="line"><span class="attr">description:</span> <span class="string">''</span></span><br><span class="line"><span class="attr">keywords:</span></span><br><span class="line"><span class="attr">author:</span> <span class="string">Alderaan</span> <span class="comment"># 作者名称</span></span><br><span class="line"><span class="attr">language:</span> <span class="string">zh-CN</span></span><br><span class="line"><span class="attr">timezone:</span> <span class="string">''</span></span><br></pre></td></tr></table></figure><hr><h2 id="文章开启版权说明"><a href="#文章开启版权说明" class="headerlink" title="文章开启版权说明"></a>文章开启版权说明</h2><p>​    新版<strong>nexT</strong>已增加版权说明模块,只需要在文章开头设置<code>copyright: true</code>即可,也可以修改<code>~/scaffolds/post.md</code> 文件,设置新建文章自动开启 <code>copyright</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></pre></td><td class="code"><pre><span class="line"><span class="meta">---</span></span><br><span class="line"><span class="attr">title:</span> <span class="string">&#123;&#123;</span> <span class="string">title</span> <span class="string">&#125;&#125;</span></span><br><span class="line"><span class="attr">date:</span> <span class="string">&#123;&#123;</span> <span class="string">date</span> <span class="string">&#125;&#125;</span></span><br><span class="line"><span class="attr">copyright:</span> <span class="literal">true</span> <span class="comment"># 设置默认开启版权说明</span></span><br><span class="line"><span class="meta">---</span></span><br></pre></td></tr></table></figure><hr><h2 id="添加「标签」页面"><a href="#添加「标签」页面" class="headerlink" title="添加「标签」页面"></a>添加「标签」页面</h2><p>新建「标签」页面,并在菜单中显示「标签」链接。「标签」页面将展示站点的所有标签,若你的所有文章都未包含标签,此页面将是空的。 底下代码是一篇包含标签的文章的例子:</p><figure class="highlight plain"><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><span class="line">title: 标签测试文章</span><br><span class="line">tags:</span><br><span class="line">  - Testing</span><br><span class="line">  - Another Tag</span><br><span class="line">---</span><br></pre></td></tr></table></figure><p>请参阅官方 <a href="https://hexo.io/zh-cn/docs/front-matter.html#分类和标签" target="_blank" rel="noopener">Hexo 的分类与标签文档</a>,了解如何为文章添加标签或者分类。</p><ul><li><a href="http://theme-next.iissnan.com/theme-settings.html#new-page-tags" target="_blank" rel="noopener">新建页面</a></li><li><a href="http://theme-next.iissnan.com/theme-settings.html#set-page-tags" target="_blank" rel="noopener">设置页面类型</a></li><li><a href="http://theme-next.iissnan.com/theme-settings.html#update-menu-for-tags-page" target="_blank" rel="noopener">修改菜单</a></li></ul><p>在终端窗口下,定位到 Hexo 站点目录下。使用 <code>hexo new page</code> 新建一个页面,命名为 <code>tags</code> :</p><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">$ cd your-hexo-site</span><br><span class="line">$ hexo new page tags</span><br></pre></td></tr></table></figure><p><strong>注意:</strong>如果有集成评论服务,页面也会带有评论。 若需要关闭的话,请添加字段 <code>comments</code> 并将值设置为 <code>false</code>,如:</p><p>禁用评论示例</p><figure class="highlight plain"><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><span class="line">title: 标签</span><br><span class="line">date: 2014-12-22 12:39:04</span><br><span class="line">type: &quot;tags&quot;</span><br><span class="line">comments: false</span><br><span class="line">---</span><br></pre></td></tr></table></figure><hr><h2 id="添加「分类」页面"><a href="#添加「分类」页面" class="headerlink" title="添加「分类」页面"></a>添加「分类」页面</h2><p>​    新建「分类」页面,并在菜单中显示「分类」链接。「分类」页面将展示站点的所有分类,若你的所有文章都未包含分类,此页面将是空的。 底下代码是一篇包含分类的文章的例子:</p><figure class="highlight plain"><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><span class="line">title: 分类测试文章</span><br><span class="line">categories: Testing</span><br><span class="line">---</span><br></pre></td></tr></table></figure><p>​    请参阅官方 <a href="https://hexo.io/zh-cn/docs/front-matter.html#分类和标签" target="_blank" rel="noopener">Hexo 的分类与标签文档</a>,了解如何为文章添加标签或者分类。</p><ul><li><p><a href="http://theme-next.iissnan.com/theme-settings.html#new-page-categories" target="_blank" rel="noopener">新建页面</a></p></li><li><p><a href="http://theme-next.iissnan.com/theme-settings.html#set-page-categories" target="_blank" rel="noopener">设置页面类型</a></p></li><li><p><a href="http://theme-next.iissnan.com/theme-settings.html#update-menu-for-categories-page" target="_blank" rel="noopener">修改菜单</a></p><p>在终端窗口下,定位到 Hexo 站点目录下。使用 <code>hexo new page</code> 新建一个页面,命名为 <code>categories</code> :</p></li></ul><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">$ cd your-hexo-site</span><br><span class="line">$ hexo new page categories</span><br></pre></td></tr></table></figure><p>​    <strong>注意:</strong>如果有集成评论服务,页面也会带有评论。 若需要关闭的话,请添加字段 <code>comments</code> 并将值设置为 <code>false</code>,如:</p><p>​    禁用评论示例</p><figure class="highlight plain"><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><span class="line">title: 分类</span><br><span class="line">date: 2014-12-22 12:39:04</span><br><span class="line">type: &quot;categories&quot;</span><br><span class="line">comments: false</span><br><span class="line">---</span><br></pre></td></tr></table></figure><hr><h2 id="开启网站计数"><a href="#开启网站计数" class="headerlink" title="开启网站计数"></a>开启网站计数</h2><p>​    在<strong>主题配置文件</strong>中搜索<code>busuanzi_count</code>,做出如下修改:</p><figure class="highlight plain"><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><span class="line"># Show Views &#x2F; Visitors of the website &#x2F; page with busuanzi.</span><br><span class="line"># Get more information on http:&#x2F;&#x2F;ibruce.info&#x2F;2015&#x2F;04&#x2F;04&#x2F;busuanzi</span><br><span class="line">busuanzi_count:</span><br><span class="line">  enable: true # 更改为true开启计数</span><br><span class="line">  total_visitors: true</span><br><span class="line">  total_visitors_icon: fa fa-user</span><br><span class="line">  total_views: true</span><br><span class="line">  total_views_icon: fa fa-eye</span><br><span class="line">  post_views: true</span><br><span class="line">  post_views_icon: fa fa-eye</span><br></pre></td></tr></table></figure><hr><h2 id="开启文章底部标签图标显示"><a href="#开启文章底部标签图标显示" class="headerlink" title="开启文章底部标签图标显示"></a>开启文章底部标签图标显示</h2><p>​    在<strong>主题配置文件</strong>中搜索<code>tag_icon</code>,做出如下修改:</p><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"># Use icon instead of the symbol # to indicate the tag at the bottom of the post</span><br><span class="line">tag_icon: true # 更改为true开启图标显示,默认为&#39;#&#39;号</span><br></pre></td></tr></table></figure><hr><h2 id="添加Live2D宠物"><a href="#添加Live2D宠物" class="headerlink" title="添加Live2D宠物"></a>添加Live2D宠物</h2><p>​    首先在博客目录下执行:</p><figure class="highlight cmd"><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><span class="line">#<span class="built_in">cmd</span> 进入博客根目录</span><br><span class="line">#安装 hexo-helper-live2d</span><br><span class="line">npm install hexo-helper-live2d -save</span><br></pre></td></tr></table></figure><p>​    在<strong>站点配置文件</strong>尾部新增:</p><figure class="highlight yml"><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></pre></td><td class="code"><pre><span class="line"><span class="comment"># Live2d</span></span><br><span class="line"><span class="attr">live2d:</span></span><br><span class="line">  <span class="attr">enable:</span> <span class="literal">true</span></span><br><span class="line">  <span class="attr">scriptFrom:</span> <span class="string">local</span></span><br><span class="line">  <span class="attr">pluginRootPath:</span> <span class="string">live2dw/</span></span><br><span class="line">  <span class="attr">pluginJsPath:</span> <span class="string">lib/</span></span><br><span class="line">  <span class="attr">pluginModelPath:</span> <span class="string">assets/</span></span><br><span class="line">  <span class="attr">model:</span></span><br><span class="line">    <span class="attr">use:</span> <span class="string">live2d-widget-model-hijiki</span></span><br><span class="line">  <span class="attr">display:</span></span><br><span class="line">    <span class="attr">position:</span> <span class="string">right</span></span><br><span class="line">    <span class="attr">width:</span> <span class="number">150</span></span><br><span class="line">    <span class="attr">height:</span> <span class="number">300</span></span><br><span class="line">  <span class="attr">mobile:</span></span><br><span class="line">    <span class="attr">show:</span> <span class="literal">false</span></span><br></pre></td></tr></table></figure><p>​    <code>npm</code>安装需要的宠物文件</p><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">npm install &#123;packagename&#125;</span><br></pre></td></tr></table></figure><p>​    如本博客宠物名为hijiki, 则为 <code>npm install live2d-widget-model-hijiki</code>,其他宠物包点击<a href="https://github.com/xiazeyu/live2d-widget-models" target="_blank" rel="noopener">live2d-widget-models</a>。详细内容可参考<a href="https://github.com/EYHN/hexo-helper-live2d" target="_blank" rel="noopener"><strong>hexo-helper-live2d</strong></a>。</p><hr>]]></content>
    
    <summary type="html">
    
      &lt;p&gt;​    本文主要说明在&lt;strong&gt;Hexo&lt;/strong&gt;博客&lt;strong&gt;nexT&lt;/strong&gt;主题下如何进行美化,具体对应效果可通过本博客页面进行查看。&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Hexo version: 4.2.0&lt;/li&gt;
&lt;li&gt;nexT version:7.8.0&lt;/li&gt;
&lt;/ul&gt;
    
    </summary>
    
    
      <category term="Hexo" scheme="https://alderaan.xyz/categories/Hexo/"/>
    
    
      <category term="Hexo" scheme="https://alderaan.xyz/tags/Hexo/"/>
    
  </entry>
  
  <entry>
    <title>在GitHub上搭建Hexo个人博客</title>
    <link href="https://alderaan.xyz/2020/05/03/hexo-install-and-deploy/"/>
    <id>https://alderaan.xyz/2020/05/03/hexo-install-and-deploy/</id>
    <published>2020-05-03T02:04:45.000Z</published>
    <updated>2020-05-07T03:46:42.729Z</updated>
    
    <content type="html"><![CDATA[<h1 id="概述"><a href="#概述" class="headerlink" title="概述"></a>概述</h1><p>​    近来发现,之前学习过、实践过的东西,要用的时候经常一时想不起来。习惯性添加进谷歌浏览器的书签,也会因为对方博客文章删除等无法继续看到。特别的是,部署一个东西需要看几个网上资源才可以完成,书签列表越来越长,难以维护。为此,觉得还是很有必要通过写博客的方式进行分类记录,也方便分享经验。本着<code>能折腾就不闲着</code>的宗旨,在网上查阅有关资料后,决定在<strong>GitHub</strong>上搭建<strong>Hexo</strong>个人博客,顺便学习使用<strong>Markdown</strong>。</p><a id="more"></a><h1 id="准备工作"><a href="#准备工作" class="headerlink" title="准备工作"></a>准备工作</h1><h2 id="安装Git"><a href="#安装Git" class="headerlink" title="安装Git"></a>安装<strong>Git</strong></h2><p>​    在<strong>Git</strong>的官方<a href="https://git-scm.com/downloads" target="_blank" rel="noopener">下载地址</a>上,选择要安装平台的安装文件进行安装</p><p><img src="https://alderaan.xyz/2020/05/03/hexo-install-and-deploy/20200503-111152.jpg" alt="Git官方下载地址截图"></p><p>​    上述图片是在Mac OS上访问网页的截图,官网一般会自动检测当前电脑的系统,如果是Windows上浏览网页右侧显示会略有不同,当然也可以在Downloads下选择特定平台的版本安装文件。</p><h2 id="安装Node-js"><a href="#安装Node-js" class="headerlink" title="安装Node.js"></a>安装<strong>Node.js</strong></h2><p>​    在<strong>Node.js</strong>的官方<a href="https://nodejs.org/en/" target="_blank" rel="noopener">下载地址</a>上,选择要安装平台的安装文件进行安装</p><p><img src="https://alderaan.xyz/2020/05/03/hexo-install-and-deploy/20200503-114433.jpg" alt="Node.js官方下载地址截图"></p><p>​    这里我选择的是12.16.3 LTS版本进行安装。</p><h1 id="安装Hexo"><a href="#安装Hexo" class="headerlink" title="安装Hexo"></a>安装Hexo</h1><h2 id="执行安装命令"><a href="#执行安装命令" class="headerlink" title="执行安装命令"></a>执行安装命令</h2><p>​    在命令行执行以下命令(Mac、Linux下需要加上sudo权限)</p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ npm install -g hexo</span><br></pre></td></tr></table></figure><h2 id="初始化网站"><a href="#初始化网站" class="headerlink" title="初始化网站"></a>初始化网站</h2><p>​    在磁盘上创建好一个文件夹(本文章文件夹名为blog),用于保存网站文件,并切换到文件夹后,执行一下命令</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><span class="line">$ <span class="built_in">cd</span> blog</span><br><span class="line">$ hexo init</span><br></pre></td></tr></table></figure><h2 id="生成默认网页"><a href="#生成默认网页" class="headerlink" title="生成默认网页"></a>生成默认网页</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ hexo generate <span class="comment"># 也可以简写为 hexo g</span></span><br></pre></td></tr></table></figure><h2 id="启动本地预览服务"><a href="#启动本地预览服务" class="headerlink" title="启动本地预览服务"></a>启动本地预览服务</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ hexo server <span class="comment"># 也可以简写为 hexo s</span></span><br></pre></td></tr></table></figure><p>​    默认的本地预览服务地址为 <a href="http://localhost:4000" target="_blank" rel="noopener">http://localhost:4000</a> ,需要先确保端口4000没有被占用,以免影响访问网页。不出意外,在浏览器上可以看到如下默认网页。</p><p><img src="https://alderaan.xyz/2020/05/03/hexo-install-and-deploy/20200503-205440.jpg" alt="Hexo博客默认主题Hello World页面"></p><h2 id="修改主题"><a href="#修改主题" class="headerlink" title="修改主题"></a>修改主题</h2><p>​    如果对默认主题风格不满意,可以在hexo的<a href="https://hexo.io/themes/" target="_blank" rel="noopener">官网</a>上寻找自己喜欢的主题,并下载到theme目录下面。本博客使用的是NexT主题,可执行如下代码下载</p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ git <span class="built_in">clone</span> https://github.com/iissnan/hexo-theme-next themes/next <span class="comment"># 若通过git clone下载,后续如果修改了主题配置,则无法提交修改后子模块源码到GitHub,建议下载后手动拷贝到themes文件夹下</span></span><br></pre></td></tr></table></figure><p>​    在 Hexo 中有两份主要的配置文件,其名称都是 <code>_config.yml</code>。 其中,一份位于站点根目录下,主要包含 Hexo 本身的配置;另一份位于主题目录下,这份配置由主题作者提供,主要用于配置主题相关的选项。</p><p>​    为了描述方便,在以下说明中,将前者称为 <strong>站点配置文件</strong>, 后者称为 <strong>主题配置文件</strong>。打开 <strong>站点配置文件</strong>, 找到 <code>theme</code> 字段,并将其值更改为 <code>next</code>,以启用 NexT 主题</p><blockquote><p>theme: next</p></blockquote><p>​    在切换主题之后、验证之前, 我们最好使用 <code>hexo clean</code> 来清除 Hexo 的缓存。重新执行<code>hexo g</code>和<code>hexo s</code>即可查看应用新主题后的默认网页。</p><h1 id="部署到GitHub"><a href="#部署到GitHub" class="headerlink" title="部署到GitHub"></a>部署到GitHub</h1><h2 id="配置免密SSH登陆"><a href="#配置免密SSH登陆" class="headerlink" title="配置免密SSH登陆"></a>配置免密SSH登陆</h2><p>​    由于Hexo博客文章是通过提交代码实现,所以需要拥有github传输权限,但是直接使用用户名和密码不够安全,所以我们使用SSH Key来解决本地和服务器的连接问题。</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><span class="line">$ <span class="built_in">cd</span> ~/.ssh </span><br><span class="line">$ ls <span class="comment">#检查本机已存在的ssh密钥</span></span><br></pre></td></tr></table></figure><p>​    如果没有任何结果,说明你是第一次使用git;如果仅有known_hosts文件,没有包含<code>id_rsa</code>字样文件,则需要创建SSH Key:</p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ ssh-keygen -t rsa -C <span class="string">"邮件地址"</span></span><br></pre></td></tr></table></figure><p>​    然后连续3次回车(默认不添加密码),最终会生成两个文件(<code>id_rsa</code>和<code>id_rsa.pub</code>)在用户目录下,打开用户目录,找到<code>.ssh/id_rsa.pub</code>文件,执行</p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ cat id_rsa.pub</span><br></pre></td></tr></table></figure><p>​    并复制里面的内容(<code>ssh-rsa</code>开头、你输入的<code>邮件地址</code>内容结尾),打开你的github主页,进入Settings -&gt; SSH and GPG keys -&gt; New SSH key:</p><p><img src="https://alderaan.xyz/2020/05/03/hexo-install-and-deploy/20200503-193801.jpg" alt="SSH配置截图"></p><p>​    将刚复制的内容粘贴到Key那里,Title按实际需要填写内容,保存后测试是否配置成功。</p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ ssh -T git@github.com <span class="comment">#注意地址不用改</span></span><br></pre></td></tr></table></figure><p>​    如果提示<code>Are you sure you want to continue connecting (yes/no)?</code>,输入yes,如果返回如下信息,说明SSH已配置成功:</p><blockquote><p>Hi XXX! You’ve successfully authenticated, but GitHub does not provide shell access.</p></blockquote><h2 id="创建个人主页仓库"><a href="#创建个人主页仓库" class="headerlink" title="创建个人主页仓库"></a>创建个人主页仓库</h2><p><img src="https://alderaan.xyz/2020/05/03/hexo-install-and-deploy/20200503-202952.jpg" alt="创建Github仓库截图"></p><p>​    这里需要注意的是,仓库名字格式为<code>xxx.github.io</code>,且前缀需要和Username一致,如果你的github账户名为blog,那么对应的的仓库名为blog.github.io。新建成功后,复制SSH地址。</p><p><img src="https://alderaan.xyz/2020/05/03/hexo-install-and-config/20200503-203256.jpg" alt="SSH地址截图"></p><h2 id="绑定个人域名-可选"><a href="#绑定个人域名-可选" class="headerlink" title="绑定个人域名(可选)"></a>绑定个人域名(可选)</h2><p>​    如果不绑定域名,只能通过默认的 <code>xxx.github.io</code> 来访问,如果你想更个性一点,可以在阿里云上注册一个域名(需要实名认证),并到控制台-&gt;域名-&gt;解析-&gt;解析设置-&gt;添加记录。</p><p>​    域名解析配置最常见有2种方式,CNAME和A记录,CNAME填写域名,A记录填写IP,由于不带www方式只能采用A记录,所以必须先ping一下<code>你Username.github.io</code>的IP,然后到你的域名DNS设置页,将A记录指向你ping得到的IP,将CNAME指向<code>Username.github.io</code>,这样可以保证无论是否添加www都可以访问,如下所示:</p><p><img src="https://alderaan.xyz/2020/05/03/hexo-install-and-deploy/20200503-200236.jpg" alt="域名解析设置截图"></p><p>​    此时需要到仓库下面,选择<code>Settings</code>-&gt;<code>options</code>,并下拉滚动条到<strong>GitHub Pages</strong>-&gt;<code>Custom domain</code>内填写上你的个人域名地址,如下所示:</p><p><img src="https://alderaan.xyz/2020/05/03/hexo-install-and-deploy/20200503-200812.jpg" alt="GitHub Pages配置截图"></p><p>​    可以开启<strong>Enforce HTTPS</strong>,个人页面Github会自动添加HTTPS证书,不会提示连接不安全的问题。</p><blockquote><p>此时还不能直接通过域名验证,由于阿里云免费的域名解析需要10分钟时间才能完全同步,且Github会自动申请添加HTTPS证书,需要一定时间。建议等待十分钟后,再查看是否可以正常访问。</p></blockquote><h2 id="上传Hexo生成的博客"><a href="#上传Hexo生成的博客" class="headerlink" title="上传Hexo生成的博客"></a>上传Hexo生成的博客</h2><p>​    hexo可以通过命令直接上传到git,但需要安装一个插件:</p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ npm install hexo-deployer-git --save</span><br></pre></td></tr></table></figure><p>​    安装后,打开<strong>站点配置文件</strong>,找到<code>deploy</code>部分,修改<code>repository</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><span class="line"><span class="attr">deploy:</span></span><br><span class="line"><span class="attr">type:</span> <span class="string">git</span>  </span><br><span class="line"><span class="attr">repository:</span> <span class="string">git@github.com:Username/Username.github.io.git</span>  </span><br><span class="line"><span class="attr">branch:</span> <span class="string">master</span></span><br></pre></td></tr></table></figure><p>​    此时,到blog下输入</p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ hexo deploy <span class="comment"># 也可以简写为 hexo d</span></span><br></pre></td></tr></table></figure><p>​    就会将本次有改动的代码全部提交到<code>master</code>:</p><p><img src="https://alderaan.xyz/2020/05/03/hexo-install-and-deploy/20200503-202546.jpg" alt="hexo d命令结果截图"></p><h2 id="上传Hexo博客源码-可选"><a href="#上传Hexo博客源码-可选" class="headerlink" title="上传Hexo博客源码(可选)"></a>上传Hexo博客源码(可选)</h2><p>​    为方便在MacOS、Windows不同电脑上随时编辑博客,且防止当前电脑故障,导致找不到Hexo配置及博文原始md文件,可以在存放Hexo博客生成的页面上创建一个新分支source,用于专门提交博客源码。</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><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><span class="line">$ <span class="built_in">cd</span> blog <span class="comment"># 切换到博客文件夹下</span></span><br><span class="line">$ git init <span class="comment"># 初始化git</span></span><br><span class="line">$ git remote add origin https://github.com/Username/Username.github.io.git <span class="comment"># 替换为你实际的git地址</span></span><br><span class="line">$ git checkout -b <span class="built_in">source</span> <span class="comment"># 创建并切换到新分支source</span></span><br><span class="line">$ git add . <span class="comment"># 添加当前所有文件(Hexo博客源码自带上传规则,会自动排出public等博客会自动生成的文件)</span></span><br><span class="line">$ git commit -m <span class="string">"your description"</span> <span class="comment"># 添加提交版本描述</span></span><br><span class="line">$ git push origin <span class="built_in">source</span> <span class="comment">#提交Hexo博客源码到source分支</span></span><br></pre></td></tr></table></figure><p>​    由于<strong>站点配置文件</strong>指定了上传博客网页的是master分支,所以提交Hexo博客源码切换的<code>source</code>分支,不会影响到<code>hexo d</code>的正常提交,两者互不冲突。</p><p>​    至此,Hexo博客的安装部署工作已经完成!</p>]]></content>
    
    <summary type="html">
    
      &lt;h1 id=&quot;概述&quot;&gt;&lt;a href=&quot;#概述&quot; class=&quot;headerlink&quot; title=&quot;概述&quot;&gt;&lt;/a&gt;概述&lt;/h1&gt;&lt;p&gt;​    近来发现,之前学习过、实践过的东西,要用的时候经常一时想不起来。习惯性添加进谷歌浏览器的书签,也会因为对方博客文章删除等无法继续看到。特别的是,部署一个东西需要看几个网上资源才可以完成,书签列表越来越长,难以维护。为此,觉得还是很有必要通过写博客的方式进行分类记录,也方便分享经验。本着&lt;code&gt;能折腾就不闲着&lt;/code&gt;的宗旨,在网上查阅有关资料后,决定在&lt;strong&gt;GitHub&lt;/strong&gt;上搭建&lt;strong&gt;Hexo&lt;/strong&gt;个人博客,顺便学习使用&lt;strong&gt;Markdown&lt;/strong&gt;&lt;/p&gt;
    
    </summary>
    
    
      <category term="Hexo" scheme="https://alderaan.xyz/categories/Hexo/"/>
    
    
      <category term="Hexo" scheme="https://alderaan.xyz/tags/Hexo/"/>
    
      <category term="Github" scheme="https://alderaan.xyz/tags/Github/"/>
    
  </entry>
  
</feed>