-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsearch.xml
More file actions
61 lines (61 loc) · 6.96 KB
/
search.xml
File metadata and controls
61 lines (61 loc) · 6.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?xml version="1.0" encoding="utf-8"?>
<search>
<entry>
<title>如何零基础搭建一个基于Hexo+Next和Github的博客</title>
<url>/2024/02/14/%E5%9F%BA%E4%BA%8Ehexo%E5%92%8Cgithub%E7%9A%84%E5%8D%9A%E5%AE%A2%E6%90%AD%E5%BB%BA%E6%95%99%E7%A8%8B/</url>
<content><![CDATA[<p>刚搭完就来写教程了(<del>不然过段时间估计就又要鸽了</del>)</p>
<span id="more"></span>
<h1 id="准备工作:"><a href="#准备工作:" class="headerlink" title="准备工作:"></a>准备工作:</h1><h2 id="Hexo"><a href="#Hexo" class="headerlink" title="Hexo"></a>Hexo</h2><p>Hexo 基于 node.js,所以首先我们要在本地安装<a href="https://nodejs.org/en/">node.js</a>和<a href="https://git-scm.com/">git</a>,除了安装位置其他全部默认就行。</p>
<p>下载之后找到cmd,分别输入 <code>node -v</code>、<code>npm -v</code> 和 <code>git --version</code>,如果出现版本号说明安装成功。</p>
<h2 id="Github-的账号注册"><a href="#Github-的账号注册" class="headerlink" title="Github 的账号注册"></a>Github 的账号注册</h2><p>需要准备好一个邮箱和一个<strong>科学上网工具</strong>,其他不用多说。</p>
<h1 id="搭建博客"><a href="#搭建博客" class="headerlink" title="搭建博客"></a>搭建博客</h1><h2 id="初始化离线博客"><a href="#初始化离线博客" class="headerlink" title="初始化离线博客"></a>初始化离线博客</h2><p>新建一个文件夹 hexo,打开后在空白处右键,选择 <code>Git Bash Here</code>(如果没有就选择 <code>显示更多选项</code>-><code>Git Bash Here</code>),会打开一个窗口。</p>
<p>在 git 窗口中依次输入以下命令:<br><figure class="highlight plaintext"><table><tr><td class="code"><pre><span class="line">npm install hexo-cli -g</span><br><span class="line">hexo init blog</span><br><span class="line">cd blog</span><br><span class="line">npm install</span><br><span class="line">hexo server</span><br></pre></td></tr></table></figure></p>
<p>全部输入完成后,hexo 文件夹中便会生成一个 blog 子文件夹,并且 blog 文件夹里面包含有很多信息:</p>
<p>node_modules: 依赖包</p>
<p>public:存放生成的页面</p>
<p>scaffolds:生成文章的一些模板</p>
<p>source:用来存放你的文章</p>
<p>themes:主题</p>
<p>然后输入</p>
<figure class="highlight plaintext"><table><tr><td class="code"><pre><span class="line">hexo g</span><br><span class="line">hexo s</span><br></pre></td></tr></table></figure>
<p>如果显示 <code>Hexo is running at http://localhost:4000.</code> 则说明配置成功,打开浏览器,在浏览器输入 <a href="http://localhost:4000">http://localhost:4000</a> 即可进入你的初始默认博客。</p>
<p>但这只是一个离线博客,也就是说只有你能看见,接下来我们就需要用 ssh 功能让博客对外开放。</p>
<h2 id="上传-Github-仓库"><a href="#上传-Github-仓库" class="headerlink" title="上传 Github 仓库"></a>上传 Github 仓库</h2><h3 id="创建-Github-仓库"><a href="#创建-Github-仓库" class="headerlink" title="创建 Github 仓库"></a>创建 Github 仓库</h3><p>首先创建一个 Github 仓库,名称格式为 <code>你的 Github 用户名.github.io</code>,选择 <code>public</code>,勾选 <code>add a README file</code>。</p>
<h3 id="配置-Github-的-SSH"><a href="#配置-Github-的-SSH" class="headerlink" title="配置 Github 的 SSH"></a>配置 Github 的 SSH</h3><p>回到 Git 窗口,输入:</p>
<p>设置用户名和邮箱:<br><figure class="highlight plaintext"><table><tr><td class="code"><pre><span class="line">git config --global user.name "你的 GitHub 的用户名"</span><br><span class="line">git config --global user.email "你的注册 GitHub 的邮箱"</span><br></pre></td></tr></table></figure></p>
<p>创建 ssh 密钥文件:<br><figure class="highlight plaintext"><table><tr><td class="code"><pre><span class="line">ssh-keygen -t rsa -C "Github 注册的邮箱地址"</span><br></pre></td></tr></table></figure></p>
<p>一直按回车,直到出现一个奇怪的图,找到 <code>C:\Users\你的用户名\.ssh\id_rsa.pub</code>,用记事本打开后把里面的东西<strong>完整</strong>复制下来。</p>
<p>然后进入 Github,点击右上角头像,点击 <code>Settings</code>,点击左侧的 <code>SSH and GPG keys</code>,点击右上方的 <code>New SSH key</code>,这时候要填两个东西,<code>Title</code> 想填什么填什么,<code>Key</code> 把刚刚复制的粘贴进去。</p>
<p>检测是否连接成功:<br><figure class="highlight plaintext"><table><tr><td class="code"><pre><span class="line">ssh git@github.com</span><br></pre></td></tr></table></figure><br>如果出现 <code>Hi xxx! You've successfully authenticated...</code> 的提示,就说明连接成功。</p>
<h3 id="配置-config-yml-文件"><a href="#配置-config-yml-文件" class="headerlink" title="配置 _config.yml 文件"></a>配置 _config.yml 文件</h3><p>将 <code>blog</code> 文件夹中 <code>_config.yml</code> 最后一段</p>
<figure class="highlight plaintext"><table><tr><td class="code"><pre><span class="line"># Deployment</span><br><span class="line">## Docs: https://hexo.io/docs/one-command-deployment</span><br><span class="line">deploy: </span><br><span class="line"> type: ''</span><br></pre></td></tr></table></figure>
<p>修改为</p>
<figure class="highlight plaintext"><table><tr><td class="code"><pre><span class="line"># Deployment</span><br><span class="line">## Docs: https://hexo.io/docs/one-command-deployment</span><br><span class="line">deploy: </span><br><span class="line"> type: git</span><br><span class="line"> repository: git@github.com:用户名/用户名.github.io.git</span><br><span class="line"> branch: master</span><br></pre></td></tr></table></figure>
<p>(有条件的建议用 vscode,没条件的就用记事本)</p>
<p>然后就可以在 Git 中输入</p>
<figure class="highlight plaintext"><table><tr><td class="code"><pre><span class="line">hexo d</span><br></pre></td></tr></table></figure>
<p>将博客上传到 Github 了。</p>
<h1 id="博客个性化"><a href="#博客个性化" class="headerlink" title="博客个性化"></a>博客个性化</h1><p>施工中…</p>
]]></content>
<categories>
<category>blog</category>
</categories>
<tags>
<tag>blog</tag>
</tags>
</entry>
<entry>
<title>博客终于搭好啦</title>
<url>/2024/02/14/%E5%8D%9A%E5%AE%A2%E7%BB%88%E4%BA%8E%E6%90%AD%E5%A5%BD%E5%95%A6/</url>
<content><![CDATA[<p>经过两天的<del>爆肝</del>瞎摸索,终于让我把博客给搭出来了(不容易啊)</p>
<span id="more"></span>
<p>后续有时间的话试试能不能写篇搭博客的教程,还有hexo插件,mathjax渲染之类的(<del>flag++</del>)</p>
]]></content>
<categories>
<category>blog</category>
</categories>
<tags>
<tag>blog</tag>
</tags>
</entry>
</search>