同一条船上的人 發表於 2021-2-26 11:06:00

Hexo+Github搭建教程

<h1 id="准备环境">准备环境</h1>
<ol>
<li>NodeJs,Hexo是基于NodeJs驱动的一款博客框架</li>
<li>Git,</li>
<li>npm</li>
</ol>
<h1 id="安装hexo">安装Hexo</h1>
<p>在某个文件夹下,右键打开git bash执行以下命令:</p>
<pre><code class="language-sh">npm install -g hexo-cli
</code></pre>
<p>之后执行下列命令:</p>
<pre><code class="language-sh">hexo init filename
cd filename
npm install
</code></pre>
<p>新建完成后,运行hexo s,其中s是sever的缩写。之后访问 http://localhost:4000 就可以预览效果了。</p>
<pre><code class="language-sh">hexo s
</code></pre>
<h1 id="github">Github</h1>
<ol>
<li>账号注册</li>
<li>创建一个仓库</li>
</ol>
<h1 id="配置ssh">配置SSH</h1>
<p>有ssh则使用下列命令查看:</p>
<pre><code>cat ~/.ssh/id_rsa.pub
</code></pre>
<p>没有ssh则执行以下命令生成:</p>
<pre><code>git config --global user.name "用户名"
git config --global user.email "邮箱地址"
ssh-keygen -t rsa -C "上面的邮箱"
</code></pre>
<p>之后将id_rsa.pub(公钥)添加到GitHub ssh key上。</p>
<h1 id="部署">部署</h1>
<p>修改 _ config.yml文件,在文件最后:</p>
<pre><code>deploy:
type: git
repo: 仓库git地址,不用http
branch: 分支名称
</code></pre>
<p>安装部署插件hexo-deployer-git</p>
<pre><code>npm install hexo-deployer-git --save
</code></pre>
<p>本地推送:</p>
<pre><code>hexo clean &amp;&amp; hexo g &amp;&amp; hexo s
</code></pre>
<p>远程推送:</p>
<pre><code>hexo clean &amp;&amp; hexo g &amp;&amp; hexo d
</code></pre>
<h1 id="写作">写作</h1>
<p>在文件根目录下打开git bash,执行命令,创建新md文件,在./source/_posts下编辑即可:</p>
<pre><code>hexo new 文章标题
</code></pre><br><br>
来源:https://www.cnblogs.com/myqx/p/14451184.html
頁: [1]
查看完整版本: Hexo+Github搭建教程