index.html 40.3 KB
Newer Older
T
TRHX 已提交
1
<!DOCTYPE html>
T
TRHX 已提交
2
<html>
T
TRHX 已提交
3 4
<head>
  <meta charset="utf-8">
T
TRHX 已提交
5
  
T
TRHX 已提交
6 7 8 9 10 11 12 13 14 15 16 17
  <title>TRHX&#39;Blog</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="description" content="一个大学生用于自学的个人博客">
<meta property="og:type" content="website">
<meta property="og:title" content="TRHX&#39;Blog">
<meta property="og:url" content="http://yoursite.com/index.html">
<meta property="og:site_name" content="TRHX&#39;Blog">
<meta property="og:description" content="一个大学生用于自学的个人博客">
<meta property="og:locale" content="zh-CN">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="TRHX&#39;Blog">
<meta name="twitter:description" content="一个大学生用于自学的个人博客">
T
TRHX 已提交
18
  
T
TRHX 已提交
19
    <link rel="alternative" href="/atom.xml" title="TRHX&#39;Blog" type="application/atom+xml">
T
TRHX 已提交
20 21
  
  
T
TRHX 已提交
22
    <link rel="icon" href="/img/trhx2.png">
T
TRHX 已提交
23 24
  
  
T
TRHX 已提交
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
      <link rel="stylesheet" href="//cdn.bootcss.com/animate.css/3.5.0/animate.min.css">
  
  <link rel="stylesheet" href="/css/style.css">
  <link rel="stylesheet" href="/font-awesome/css/font-awesome.min.css">
  <link rel="apple-touch-icon" href="/apple-touch-icon.png">
  
    
    
  
  
      <link rel="stylesheet" href="/fancybox/jquery.fancybox.css">
  
  <!-- 加载特效 -->
    <script src="/js/pace.js"></script>
    <link href="/css/pace/pace-theme-flash.css" rel="stylesheet" />
  <script>
      var yiliaConfig = {
          rootUrl: '/',
          fancybox: true,
          animate: true,
          isHome: true,
          isPost: false,
          isArchive: false,
          isTag: false,
          isCategory: false,
          open_in_new: false
      }
  </script>
T
TRHX 已提交
53
</head>
T
TRHX 已提交
54 55 56 57 58 59 60 61 62 63 64
<body>
  <div id="container">
    <div class="left-col">
    <div class="overlay"></div>
<div class="intrude-less">
    <header id="header" class="inner">
        <a href="/" class="profilepic">
            
            <img lazy-src="/img/trhx.png" class="js-avatar">
            
        </a>
T
TRHX 已提交
65

T
TRHX 已提交
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 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
        <hgroup>
          <h1 class="header-author"><a href="/" title="Hi Mate">TRHX</a></h1>
        </hgroup>

        
        <p class="header-subtitle">天下事有难易乎?为之,则难者亦易矣;不为,则易者亦难矣!</p>
        
        
        
            <div id="switch-btn" class="switch-btn">
                <div class="icon">
                    <div class="icon-ctn">
                        <div class="icon-wrap icon-house" data-idx="0">
                            <div class="birdhouse"></div>
                            <div class="birdhouse_holes"></div>
                        </div>
                        <div class="icon-wrap icon-ribbon hide" data-idx="1">
                            <div class="ribbon"></div>
                        </div>
                        
                        <div class="icon-wrap icon-link hide" data-idx="2">
                            <div class="loopback_l"></div>
                            <div class="loopback_r"></div>
                        </div>
                        
                        
                        <div class="icon-wrap icon-me hide" data-idx="3">
                            <div class="user"></div>
                            <div class="shoulder"></div>
                        </div>
                        
                    </div>
                    
                </div>
                <div class="tips-box hide">
                    <div class="tips-arrow"></div>
                    <ul class="tips-inner">
                        <li>菜单</li>
                        <li>标签</li>
                        
                        <li>友情链接</li>
                        
                        
                        <li>关于我</li>
                        
                    </ul>
                </div>
            </div>
        
T
TRHX 已提交
115

T
TRHX 已提交
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163
        <div id="switch-area" class="switch-area">
            <div class="switch-wrap">
                <section class="switch-part switch-part1">
                    <nav class="header-menu">
                        <ul>
                        
                            <li><a href="/Home">博客首页</a></li>
                        
                            <li><a href="/works">作品展示</a></li>
                        
                            <li><a href="/about">留言打卡</a></li>
                        
                            <li><a href="/FrontEndGuide">前端导航</a></li>
                        
                        </ul>
                    </nav>
                    <nav class="header-nav">
                        <ul class="social">
                            
                                <a class="fl Email" target="_blank" href="mailto:tanrenhou@126.com" title="Email">Email</a>
                            
                                <a class="fl github" target="_blank" href="https://github.com/TRHX" title="github">github</a>
                            
                                <a class="fl QQ" target="_blank" href="http://wpa.qq.com/msgrd?v=3&uin=2273902448&site=qq&menu=yes" title="QQ">QQ</a>
                            
                                <a class="fl CSDN" target="_blank" href="https://blog.csdn.net/qq_36759224" title="CSDN">CSDN</a>
                            
                        </ul>
                    </nav>
                </section>
                
                
                <section class="switch-part switch-part2">
                    <div class="widget tagcloud" id="js-tagcloud">
                        
                    </div>
                </section>
                
                
                
                <section class="switch-part switch-part3">
                    <div id="js-friends">
                    
                      <a target="_blank" class="main-nav-link switch-friends-link" href="http://luuman.github.io/">name</a>
                    
                    </div>
                </section>
                
T
TRHX 已提交
164

T
TRHX 已提交
165 166 167 168 169 170 171 172
                
                
                <section class="switch-part switch-part4">
                
                    <div id="js-aboutme">纯海迷、爱运动、爱交友、爱旅行、喜欢接触新鲜事物、迎接新的挑战,更爱游离于错综复杂的编码与逻辑中</div>
                </section>
                
            </div>
T
TRHX 已提交
173
        </div>
T
TRHX 已提交
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192
    </header>                
</div>
    </div>
    <div class="mid-col">
      <nav id="mobile-nav">
      <div class="overlay">
          <div class="slider-trigger"></div>
          <h1 class="header-author js-mobile-header hide"><a href="/" title="Me">TRHX</a></h1>
      </div>
    <div class="intrude-less">
        <header id="header" class="inner">
            <a href="/" class="profilepic">
                
                    <img lazy-src="/img/trhx.png" class="js-avatar">
                
            </a>
            <hgroup>
              <h1 class="header-author"><a href="/" title="Me">TRHX</a></h1>
            </hgroup>
T
TRHX 已提交
193
            
T
TRHX 已提交
194
            <p class="header-subtitle">天下事有难易乎?为之,则难者亦易矣;不为,则易者亦难矣!</p>
T
TRHX 已提交
195
            
T
TRHX 已提交
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223
            <nav class="header-menu">
                <ul>
                
                    <li><a href="/Home">博客首页</a></li>
                
                    <li><a href="/works">作品展示</a></li>
                
                    <li><a href="/about">留言打卡</a></li>
                
                    <li><a href="/FrontEndGuide">前端导航</a></li>
                
                <div class="clearfix"></div>
                </ul>
            </nav>
            <nav class="header-nav">
                <div class="social">
                    
                        <a class="Email" target="_blank" href="mailto:tanrenhou@126.com" title="Email">Email</a>
                    
                        <a class="github" target="_blank" href="https://github.com/TRHX" title="github">github</a>
                    
                        <a class="QQ" target="_blank" href="http://wpa.qq.com/msgrd?v=3&uin=2273902448&site=qq&menu=yes" title="QQ">QQ</a>
                    
                        <a class="CSDN" target="_blank" href="https://blog.csdn.net/qq_36759224" title="CSDN">CSDN</a>
                    
                </div>
            </nav>
        </header>                
T
TRHX 已提交
224
    </div>
T
TRHX 已提交
225 226 227 228 229 230 231 232 233
</nav>
      <div class="body-wrap">
  
    <article id="post-如何使用Github Pages和Hexo搭建自己独立博客" class="article article-type-post" itemscope itemprop="blogPost">
  
    <div class="article-meta">
      <a href="/2018/08/15/如何使用Github Pages和Hexo搭建自己独立博客/" class="article-date">
      <time datetime="2018-08-15T13:34:58.325Z" itemprop="datePublished">2018-08-15</time>
</a>
T
TRHX 已提交
234
    </div>
T
TRHX 已提交
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249
  
  <div class="article-inner">
    
      <input type="hidden" class="isFancy" />
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2018/08/15/如何使用Github Pages和Hexo搭建自己独立博客/">如何使用Github Pages和Hexo搭建自己独立博客</a>
    </h1>
  

      </header>
T
TRHX 已提交
250
      
T
TRHX 已提交
251 252
    
    <div class="article-entry" itemprop="articleBody">
T
TRHX 已提交
253
      
T
TRHX 已提交
254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446
          
        <center><font color="#000000" size="6" face="楷体"><strong>如何使用Github Pages和Hexo搭建自己独立博客</strong></font></center>

<hr>
<center><iframe frameborder="no" border="0" marginwidth="0" marginheight="0" width="450" height="86" src="http://music.163.com/outchain/player?type=2&id=190381&auto=1&height=66"><br></iframe></center>

<h1 id="前言"><a href="#前言" class="headerlink" title="- 前言"></a><strong>- 前言</strong></h1><p>首先感谢您能访问我的博客:<a href="http://trhx.github.io" target="_blank" rel="noopener">TRHX’Blog</a> <br></p>
<p>这是一篇有关如何使用 <font color="#DC143C">Github Pages</font><font color="#DC143C">Hexo</font> 搭建属于自己独立博客的详尽教程,本人是软件工程专业本科生,目前只学习了C和C++编程语言,对网站开发的有关知识几乎为零,这也是我搭建好自己的博客之后写的第一篇博客,刚开始搭建博客的时候自己也是网上各种百度,由于自己属于<font color="#DC143C"><strong>小白</strong></font>那种,历经了千辛万苦才弄好,所以借这个机会写一篇小白真正能看懂的博客搭建教程,教你一步一步走向成功的彼岸! <br></p>
<p>推荐文章: <a href="http://www.cnblogs.com/jhzhu/p/3893297.html" target="_blank" rel="noopener">《我为什么写博客》</a> (By 知明所以)<br>      <a href="http://mindhacks.cn/2009/02/15/why-you-should-start-blogging-now/" target="_blank" rel="noopener">《为什么你应该(从现在开始就)写博客》</a>  (By 刘未鹏 | Mind Hacks)</p>
<h1 id="入门"><a href="#入门" class="headerlink" title="- 入门"></a><strong>- 入门</strong></h1><blockquote>
<p><strong>Github Pages</strong></p>
</blockquote>
<p>Github Pages可以被认为是用户编写的、托管在github上的静态网页。使用Github Pages可以为你提供一个免费的服务器,免去了自己搭建服务器和写数据库的麻烦。此外还可以绑定自己的域名。</p>
<blockquote>
<p><strong>Hexo</strong></p>
</blockquote>
<p>Hexo 是一个快速、简洁且高效的博客框架。Hexo 使用 Markdown(或其他渲染引擎)解析文章,在几秒内,即可利用靓丽的主题生成静态网页。</p>
<h2 id="话不多说,步入正题"><a href="#话不多说,步入正题" class="headerlink" title="话不多说,步入正题"></a>话不多说,步入正题</h2><h1 id="安装Node-js"><a href="#安装Node-js" class="headerlink" title="- 安装Node.js"></a>- 安装Node.js</h1><p><a href="https://nodejs.org/en/download/" target="_blank" rel="noopener">点击此处</a>访问官网,按需下载相应版本,默认安装可以了</p>
<p><img src="https://i.imgur.com/l9qbq4X.png" alt=""></p>
<p>注:本人在安装过程中出现了Warning 1909,无法创建快捷方式,这种情况很少出现,如果在安装过程中也有这种情况请参考百度文库(win10系统实测可行):<a href="https://wenku.baidu.com/view/4ad59110964bcf84b9d57ba5.html" target="_blank" rel="noopener">《Win7 安装程序快捷方式报错 警告1909,无法创建快捷方式》</a></p>
<p><img src="https://i.imgur.com/qzNCltv.png" alt=""></p>
<h1 id="安装Git"><a href="#安装Git" class="headerlink" title="- 安装Git"></a><strong>- 安装Git</strong></h1><p><a href="https://git-scm.com/download/win" target="_blank" rel="noopener">点击此处</a>访问官网,按需下载相应版本,默认安装即可 <br><br>参考资料:<a href="https://www.cnblogs.com/jytx/p/5602927.html" target="_blank" rel="noopener">《如何在windows下安装GIT》</a>  (By 俊雨廷休)<br>     <a href="http://git.oschina.net/progit/" target="_blank" rel="noopener">《Pro Git(中文版)》</a></p>
<h1 id="检验软件是否安装成功"><a href="#检验软件是否安装成功" class="headerlink" title="- 检验软件是否安装成功"></a><strong>- 检验软件是否安装成功</strong></h1><p>同时按下 Win 键和 R 键打开运行窗口,输入 <font color="#DC143C">cmd</font> ,然后输入以下命令,有相应版本信息显示则安装成功,若不正确可以卸载软件重新安装,此外若安装成功,在桌面右键鼠标,可以看到菜单里多了<font color="#DC143C">Git GUI Here</font><font color="#DC143C">Git Bash Here</font>两个选项,第一个是<font color="#DC143C">图形界面的Git操作</font>,另一个是<font color="#DC143C">命令行</font></p>
<blockquote>
<p>$ git –version<br>$ node -v<br>$ npm -v   </p>
</blockquote>
<p><img src="https://i.imgur.com/MrqA2oy.png" alt=""><br><img src="https://i.imgur.com/EdKdq8c.png" alt=""></p>
<h1 id="Hexo安装"><a href="#Hexo安装" class="headerlink" title="- Hexo安装"></a><strong>- Hexo安装</strong></h1><p>选择一个磁盘,新建一个文件夹,自己重命名文件夹(如:我的文件夹为:<font color="#DC143C">E\TRHX_Blog</font>),博客相关文件将储存在此文件夹下,在该文件夹下右键鼠标,点击 <font color="#DC143C">Git Bash Here</font>,输入以下 npm 命令即可安装,第一个命令表示安装 hexo,第二个命令表示安装 hexo 部署到 git page 的 deployer,如图所示即为安装成功</p>
<blockquote>
<p>$ npm install hexo-cli -g<br>$ npm install hexo-deployer-git –save  </p>
</blockquote>
<p><img src="https://i.imgur.com/D4jX96g.png" alt=""></p>
<h1 id="Hexo初始化配置"><a href="#Hexo初始化配置" class="headerlink" title="- Hexo初始化配置"></a><strong>- Hexo初始化配置</strong></h1><p>在刚才新建的文件夹里面再次新建一个 <font color="#DC143C">Hexo</font> 文件夹(如:我的文件夹为:<font color="#DC143C">E\TRHX_Blog\Hexo</font>),进入该 <font color="#DC143C">Hexo</font> 文件夹右键鼠标,点击 <font color="#DC143C">Git Bash Here</font>,输入以下命令,如图所示则安装成功</p>
<blockquote>
<p>$ hexo init</p>
</blockquote>
<p><img src="https://i.imgur.com/RL60g7o.png" alt=""><br></p>
<p>Hexo 安装完成后,将会在指定文件夹中新建所需要的文件,Hexo 文件夹下的目录如下:</p>
<p><img src="https://i.imgur.com/x7h42wm.png" alt=""></p>
<h1 id="本地查看效果"><a href="#本地查看效果" class="headerlink" title="- 本地查看效果"></a><strong>- 本地查看效果</strong></h1><p>执行以下命令,执行完即可登录 <a href="http://localhost:4000/" target="_blank" rel="noopener">http://localhost:4000/</a> 查看效果</p>
<blockquote>
<p>$ hexo generate<br>$ hexo server  </p>
</blockquote>
<p>显示以下信息说明操作成功:</p>
<blockquote>
<p>INFO Hexo is running at <a href="http://0.0.0.0:4000/" target="_blank" rel="noopener">http://0.0.0.0:4000/</a>. Press Ctrl+C to stop.</p>
</blockquote>
<p>登录 <a href="http://localhost:4000/" target="_blank" rel="noopener">http://localhost:4000/</a> 查看效果:</p>
<p><img src="https://i.imgur.com/RnrEl8h.png" alt=""></p>
<h1 id="将博客部署到Github-Pages上"><a href="#将博客部署到Github-Pages上" class="headerlink" title="- 将博客部署到Github Pages上"></a><strong>- 将博客部署到Github Pages上</strong></h1><p>到目前为止,我们的本地博客就成功搭建了,但是现在我们只能通过本地连接查看博客,我们要做的是让其他人也能够访问我们的博客,这就需要我们将博客部署到Github Pages上<br></p>
<p>一、注册 Github 账户:<a href="https://github.com" target="_blank" rel="noopener">点击此处</a>访问 Github 官网,点击 Sign Up 注册账户<br></p>
<p>二、创建项目代码库:点击 <font color="#DC143C">New repository</font> 开始创建,步骤及注意事项见图:</p>
<p><img src="https://i.imgur.com/0FqXlSu.png" alt=""></p>
<p>三、配置 <font color="#DC143C">SSH</font> 密钥:只有配置好 <font color="#DC143C">SSH</font> 密钥后,我们才可以通过 git 操作实现本地代码库与 Github 代码库同步,在你第一次新建的文件夹里面(如:我的文件夹为:<font color="#DC143C">E\TRHX_Blog</font><font color="#DC143C">Git Bash Here</font> 输入以下命令:</p>
<blockquote>
<p>$ ssh-keygen -t rsa -C “your <a href="mailto:email@example.com" target="_blank" rel="noopener">email@example.com</a></p>
<font color="#00CD00">//引号里面填写你的邮箱地址,比如我的是<a href="mailto:tanrenhou@126.com" target="_blank" rel="noopener">tanrenhou@126.com</a></font>
</blockquote>
<p>之后会出现:</p>
<blockquote>
<p>Generating public/private rsa key pair.<br>Enter file in which to save the key (/c/Users/you/.ssh/id_rsa):  </p>
<font color="#00CD00">//到这里可以直接回车将密钥按默认文件进行存储</font>
</blockquote>
<p>然后会出现:</p>
<blockquote>
<p>Enter passphrase (empty for no passphrase):  </p>
<p><font color="#00CD00">//这里是要你输入密码,其实不需要输什么密码,直接回车就行</font><br>Enter same passphrase again:  </p>
</blockquote>
<p>接下来屏幕会显示:</p>
<blockquote>
<p>Your identification has been saved in /c/Users/you/.ssh/id_rsa.<br>Your public key has been saved in /c/Users/you/.ssh/id_rsa.pub.<br>The key fingerprint is:<br>这里是各种字母数字组成的字符串,结尾是你的邮箱<br>The key’s randomart image is:<br>这里也是各种字母数字符号组成的字符串  </p>
</blockquote>
<p>运行以下命令,将公钥的内容复制到系统粘贴板上</p>
<blockquote>
<p>$ clip &lt; ~/.ssh/id_rsa.pub</p>
</blockquote>
<p>四、在 GitHub 账户中添加你的公钥</p>
<p>1.登陆 GitHub,进入 <font color="#DC143C">Settings</font></p>
<p><img src="https://i.imgur.com/jzyEME2.png" alt=""></p>
<p>2.点击 <font color="#DC143C">SSH and GPG Keys</font></p>
<p><img src="https://i.imgur.com/4PAjGms.png" alt=""></p>
<p>3.选择 <font color="#DC143C">New SSH key</font></p>
<p><img src="https://i.imgur.com/CYnhV4W.png" alt=""></p>
<p>3.粘贴密钥:</p>
<p><img src="https://i.imgur.com/vnTjW4z.png" alt=""></p>
<p>五、测试</p>
<p>输入以下命令:<font color="#DC143C">注意:<a href="mailto:git@github.com" target="_blank" rel="noopener">git@github.com</a>不要做任何更改!</font></p>
<blockquote>
<p>$ ssh -T <a href="mailto:git@github.com" target="_blank" rel="noopener">git@github.com</a></p>
</blockquote>
<p>之后会显示:</p>
<p><img src="https://i.imgur.com/NLHp4nz.png" alt=""></p>
<p>输入 <font color="#DC143C">yes</font> 后会显示:</p>
<p><img src="https://i.imgur.com/UJt5utl.png" alt=""></p>
<p>此时表示设置正确</p>
<p>六、配置 Git 个人信息</p>
<p>Git 会根据用户的名字和邮箱来记录提交,GitHub 也是用这些信息来做权限的处理,输入以下命令进行个人信息的设置,把名称和邮箱替换成你自己的,名字可以不是 GitHub 的昵称,但为了方便记忆,建议与 GitHub  一致</p>
<blockquote>
<p>$ git config –global user.name “此处填你的用户名”<br>$ git config –global user.email  “此处填你的邮箱”</p>
</blockquote>
<p>到此为止 SSH Key 配置成功,本机已成功连接到 Github</p>
<h1 id="将本地的Hexo文件更新到Github的库中"><a href="#将本地的Hexo文件更新到Github的库中" class="headerlink" title="- 将本地的Hexo文件更新到Github的库中"></a><strong>- 将本地的Hexo文件更新到Github的库中</strong></h1><p>一、登录 Github 打开自己的项目 <font color="#DC143C">your name.github.io</font></p>
<p><img src="https://i.imgur.com/KWeHGF1.png" alt=""></p>
<p>二、鼠标移到 <font color="#DC143C">Clone or download</font> 按钮,选择 <font color="#DC143C">Use SSH</font></p>
<p><img src="https://i.imgur.com/nNRZVDQ.png" alt=""></p>
<p>三、一键复制地址</p>
<p><img src="https://i.imgur.com/ulwSVjM.png" alt=""></p>
<p>四、打开你创建的 <font color="#DC143C">Hexo</font> 文件夹(如:<font color="#DC143C">E:\TRHX_Blog\Hexo</font>),右键用记事本(或者Notepad++)打开该文件夹下的 <font color="#DC143C">_config.yml</font> 文件</p>
<p><img src="https://i.imgur.com/DtH87DK.png" alt=""></p>
<p>五、按下图修改 <font color="#DC143C">_config.yml</font> 文件并保存</p>
<p><img src="https://i.imgur.com/7vbeY3N.png" alt=""></p>
<p>六、在 <font color="#DC143C">Hexo</font> 文件夹下分别执行以下命令</p>
<blockquote>
<p>$ hexo g<br>$ hexo d</p>
</blockquote>
<p>或者直接执行</p>
<blockquote>
<p>$ hexo g -d</p>
</blockquote>
<p>执行完之后会让你输入你的 Github 的账号和密码,如果此时报以下错误,说明你的 deployer 没有安装成功</p>
<blockquote>
<p>ERROR Deployer not found: git</p>
</blockquote>
<p>需要执行以下命令再安装一次:</p>
<blockquote>
<p>npm install hexo-deployer-git –save</p>
</blockquote>
<p>再执行 <font color="#DC143C">hexo g -d</font>,你的博客就会部署到 Github 上了</p>
<p>七、访问博客</p>
<p>你的博客地址:<font color="#DC143C">https://你的用户名.github.io</font>,比如我的是:<font color="#DC143C"><a href="https://trhx.github.io" target="_blank" rel="noopener">https://trhx.github.io</a></font> ,现在每个人都可以通过此链接访问你的博客了</p>
<h1 id="如何在博客上发表文章"><a href="#如何在博客上发表文章" class="headerlink" title="- 如何在博客上发表文章"></a><strong>- 如何在博客上发表文章</strong></h1><p>博客已经成功搭建了,但是我们该怎么写博客呢?</p>
<p>一、新建一个空文章,输入以下命令,会在项目 <font color="#DC143C">\Hexo\source\_posts</font> 中生成 <font color="#DC143C">文章标题.md</font> 文件,文章标题根据需要命名</p>
<blockquote>
<p>$ hexo n “文章标题”</p>
</blockquote>
<p>也可以直接在 <font color="#DC143C">\Hexo\source\_posts</font> 目录下右键鼠标新建文本文档,改后缀为 <font color="#DC143C">.md</font> 即可,这种方法比较方便</p>
<p>二、用编辑器编写文章</p>
<font color="#DC143C">md</font> 全称 Markdown, Markdown 是 2004 年由 John Gruberis 设计和开发的纯文本格式的语法,非常的简单实用,常用的标记符号屈指可数,几分钟即可学会, <font color="#DC143C">.md</font> 文件可以使用支持 Markdown 语法的编辑器编辑,然后保存文件到 <font color="#DC143C">\Hexo\source\_posts</font> 文件夹下即可<br><br>推荐 Windows 上使用 <font color="#DC143C">MarkdownPad2</font> 编辑器,macOS 上使用 <font color="#DC143C">Mou</font> 编辑器,Linux 上使用 <font color="#DC143C">Remarkable</font>编辑器,Web 端上使用<font color="#DC143C">简书</font> 

<p>当我们用编辑器写好文章后,可以使用以下命令将其推送到服务器上</p>
<blockquote>
<p>$ hexo g<br>$ hexo d</p>
</blockquote>
<p>或者将两个命令合二为一输入以下命令:</p>
<blockquote>
<p>$ hexo d -g </p>
</blockquote>
<p>现在访问你的博客就可以看见写好的文章啦!</p>
<p>参考资料:<a href="https://blog.csdn.net/jinhui157/article/details/73872795" target="_blank" rel="noopener">《10款流行的Markdown编辑器,总有一款适合你》</a> (By xiaoxiao_engineer)<br>     <a href="https://www.jianshu.com/p/q81RER/" target="_blank" rel="noopener">《献给写作者的 Markdown 新手指南》</a> (By 简书)<br>     <a href="https://sspai.com/post/25137" target="_blank" rel="noopener">《认识与入门 Markdown》</a> (By Te_Lee)<br>     <a href="http://ibruce.info/2013/11/26/markdown/" target="_blank" rel="noopener">《markdown简明语法》</a> (By 不如)<br>     <a href="https://www.jianshu.com/p/191d1e21f7ed" target="_blank" rel="noopener">《markdown基本语法》</a> (By 高鸿祥)<br>     <a href="http://www.liuhaihua.cn/archives/143443.html" target="_blank" rel="noopener">《Markdown 公式指导手册》</a> (By Harries)  
     
     </p>
<h1 id="如何为博客更换自己喜欢的主题"><a href="#如何为博客更换自己喜欢的主题" class="headerlink" title="- 如何为博客更换自己喜欢的主题"></a><strong>- 如何为博客更换自己喜欢的主题</strong></h1><p>博客也搭建好了,文章也会写了,但是!!!默认的主题并不喜欢怎么办?现在,我们就来为自己的博客更换自己喜欢的主题</p>
<p><a href="https://hexo.io/themes/" target="_blank" rel="noopener">点击此处</a>进入 Hexo 官网的主题专栏,我们可以看见有许多的主题供我们选择</p>
<p><img src="https://i.imgur.com/t3aGEQ2.png" alt=""></p>
<p>我们要做的就是把主题克隆过来,在此我们以主题 <font color="#DC143C">Aero-Dual</font> 为例,点进去我们就可以看见该主题作者的博客,鼠标滑到底,我们可以看见 <font color="#DC143C">Theme By Levblanc</font> 的字样(其他主题类似),点击作者 <font color="#DC143C">Levblanc</font> ,页面就会跳转到该主题所有的相关文件在 Github 上的地址,复制该地址</p>
<p><img src="https://i.imgur.com/tzpNdzk.png" alt=""></p>
<p><img src="https://i.imgur.com/ECHuTS9.png" alt=""></p>
<p><img src="https://i.imgur.com/qBFXpOL.png" alt=""></p>
<p>再打开 <font color="#DC143C">Hexo</font> 文件夹下的 <font color="#DC143C">themes</font> 目录(如:<font color="#DC143C">E:\TRHX_Blog\Hexo\themes</font>),右键 <font color="#DC143C">Git Bash Here</font>,输入以下命令:</p>
<blockquote>
<p>$ git clone 此处填写你刚才复制的主题地址</p>
</blockquote>
<p>比如要安装 <font color="#DC143C">Aero-Dual</font> 主题,则输入命令:</p>
<blockquote>
<p>$ git clone <a href="https://github.com/levblanc/hexo-theme-aero-dual" target="_blank" rel="noopener">https://github.com/levblanc/hexo-theme-aero-dual</a></p>
</blockquote>
<p>等待下载完成后即可在 <font color="#DC143C">themes</font> 目录下生成 <font color="#DC143C">hexo-theme-aero-dual</font> 文件夹,然后打开 <font color="#DC143C">Hexo</font> 文件夹下的配置文件 <font color="#DC143C">_config.yml</font> ,找到关键字 <font color="#DC143C">theme</font>,修改参数为:<font color="#DC143C">theme:hexo-theme-aero-dual</font> (其他主题修改成相应名称即可),再次注意冒号后面有一个空格!</p>
<p><img src="https://i.imgur.com/2lUYsjZ.png" alt=""></p>
<p>返回 <font color="#DC143C">Hexo</font> 目录,右键 <font color="#DC143C">Git Bash Here</font> ,输入以下命令开始部署主题:</p>
<blockquote>
<p>$ hexo g<br>$ hexo s</p>
</blockquote>
<p>此时打开浏览器,访问 <a href="http://localhost:4000/" target="_blank" rel="noopener">http://localhost:4000/</a>  就可看见我们的主题已经更换了,如果感觉效果满意,我们就可以把它部署到Github上了</p>
<p>打开 <font color="#DC143C">Hexo</font> 文件夹,右键 <font color="#DC143C">Git Bash Here</font> ,输入以下命令:</p>
<blockquote>
<p>$ hexo clean  </p>
<p><font color="#00CD00">//该命令的作用是清除缓存,若不输入此命令,服务器有可能更新不了主题</font><br>$ hexo g -d</p>
</blockquote>
<p>此时访问自己的博客即可看见更换后的主题,但我们仍然需要对主题的相关配置进行修改,比如网站标题,图标等等,Hexo 中有两份主要的配置文件,名称都是  <font color="#DC143C">_config.yml</font> ,它们均是用于站点配置使用的。其中,一份位于站点根目录下(比如我的:<font color="#DC143C">E:\TRHX_Blog\Hexo\_config.yml</font>),主要包含 Hexo 本身整站的配置;另一份位于主题目录下(比如我的:<font color="#DC143C">E:\TRHX_Blog\Hexo\themes\hexo-theme-aero-dual\_config.yml</font>),这份配置由主题作者提供,主要用于配置主题相关的选项,一般  <font color="#DC143C">_config.yml</font>  文件里都有相关注释,按需修改即可</p>
<p>参考资料:<a href="https://www.zhihu.com/question/24422335" target="_blank" rel="noopener">《有哪些好看的 Hexo 主题?》</a> (知乎)<br>     <a href="https://hexo.io/zh-cn/docs/configuration.html" target="_blank" rel="noopener">《Hexo | 配置》</a> (Hexo官方文档)<br>     <a href="https://segmentfault.com/a/1190000002632530" target="_blank" rel="noopener">《hexo常用命令笔记》</a> (By 小弟调调)</p>
<h1 id="为你的-Hexo-博客配置个性域名"><a href="#为你的-Hexo-博客配置个性域名" class="headerlink" title="- 为你的 Hexo 博客配置个性域名"></a>- 为你的 Hexo 博客配置个性域名</h1><p>本人在配置域名的时候问题百出,百度的各种方法都不管用,打开网站总是 404,可能是我太笨了  o(╥﹏╥)o ,不过好在后来终于解决了这个问题</p>
<p>首先我们要购买域名,<a href="https://www.aliyun.com" target="_blank" rel="noopener">阿里云</a><a href="https://cloud.tencent.com" target="_blank" rel="noopener">腾讯云</a>都可以,也不贵,一年几十块钱,最便宜几块钱也能买到,以阿里云为例,我购买的域名是 <a href="http://trhx.top" target="_blank" rel="noopener">trhx.top</a>,购买过程就不赘述了,选择阿里云的解析平台,来到阿里云的管理控制台,点击进入域名解析列表或者直接点击域名后面的解析</p>
<p><img src="https://i.imgur.com/WNzFja7.png" alt=""></p>
<p>点击添加记录,需要添加两个记录,两个记录类型都是 <font color="#DC143C">CNAME</font> ,记录值都是填你自己的博客地址(比如我的是:<font color="#DC143C"><a href="http://trhx.github.io" target="_blank" rel="noopener">trhx.github.io</a></font>),第一个主机记录为 <font color="#DC143C">@</font> ,第二个主机记录为 <font color="#DC143C">www</font> ,保存之后域名解析就完成了!</p>
<p>【注:百度大多数方法是这样的:两个记录类型为 <font color="#DC143C">A</font> ,记录值都为博客的 <font color="#DC143C">IP</font> 地址,<font color="#DC143C">IP</font> 地址可以 <font color="#DC143C">cmd</font> 中输入 <font color="#DC143C">ping 你的博客地址</font> 获得(比如我的:<font color="#DC143C">ping trhx.github.io</font>),但我尝试这种方法并没有成功,目前也不知道具体原因,强调一下,我还是这方面<font color="#DC143C">小白!小白!小白!</font>所以不太懂,欢迎大佬来指点!】</p>
<p><img src="https://i.imgur.com/hf7od2h.png" alt=""></p>
<p>为了使 GitHub 接收我们的域名,还需要在博客的根目录下添加一个名为 <font color="#DC143C">CNAME</font> 的文件(<font color="#DC143C">注意不要加.txt,没有任何后缀名!</font>),这个文件放到 <font color="#DC143C">Hexo</font> 文件夹的 <font color="#DC143C">source</font> 里面,(比如我的是:<font color="#DC143C">E:\TRHX_Blog\Hexo\source</font>),文件里面填写你的域名(<font color="#DC143C">去掉www</font>),比如要填写我的域名,文件里面就放一句话:<font color="#DC143C">trhx.top</font>,经过以上操作,别人就可以通过 <a href="http://www.trhx.top" target="_blank" rel="noopener">www.trhx.top</a><a href="http://trhx.top" target="_blank" rel="noopener">trhx.top</a><a href="http://trhx.github.io" target="_blank" rel="noopener">trhx.github.io</a> 三个当中任意一个访问我的博客了!你的也一样!</p>
<p><img src="https://i.imgur.com/FeUbvsS.png" alt=""></p>
<p>如果你在其他平台购买域名,或者选择 <a href="https://www.dnspod.cn" target="_blank" rel="noopener">DNSPod</a> 等其他域名解析,操作方法大同小异,遇到问题可自行百度解决!</p>
<p>参考资料:<a href="https://zhuanlan.zhihu.com/p/27349039" target="_blank" rel="noopener">《推荐几家域名注册服务商》</a>  (By Jelly Bool)<br>     <a href="http://www.chinaz.com/web/2015/0122/380042.shtml" target="_blank" rel="noopener">《盘点十大免费DNS域名解析服务:稳定、可靠》</a></p>
<h1 id="结语"><a href="#结语" class="headerlink" title="- 结语"></a><strong>- 结语</strong></h1><p>一顿操作下来虽然有点儿累,但看见拥有了自己的博客还是非常有成就感的,人生就是需要折腾,那么现在就开始你的创作之旅吧!文章的不断积累,你会从中受益很多的!另外,这是一篇小白写的适用于小白的博客搭建教程,比较详细,有这方面基础的可以百度有简略一点儿的教程,文中如有错误还请大佬指出改正!文中涉及参考资料如有侵权请联系我删除!</p>
<hr>
<p>转载声明:商业转载请联系作者获得授权,非商业转载请注明出处 © <a href="http://trhx.github.io" target="_blank" rel="noopener">TRHX</a></p>
T
TRHX 已提交
447 448

      
T
TRHX 已提交
449
      
T
TRHX 已提交
450
    </div>
T
TRHX 已提交
451 452
    
    <div class="article-info article-info-index">
T
TRHX 已提交
453
      
T
TRHX 已提交
454 455 456
      

      
T
TRHX 已提交
457 458
      
      <div class="clearfix"></div>
T
TRHX 已提交
459
    </div>
T
TRHX 已提交
460
    
T
TRHX 已提交
461
  </div>
T
TRHX 已提交
462 463
  
</article>
T
TRHX 已提交
464

T
TRHX 已提交
465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499








  
    <article id="post-hello-world" class="article article-type-post" itemscope itemprop="blogPost">
  
    <div class="article-meta">
      <a href="/2018/08/10/hello-world/" class="article-date">
      <time datetime="2018-08-10T09:33:18.448Z" itemprop="datePublished">2018-08-10</time>
</a>
    </div>
  
  <div class="article-inner">
    
      <input type="hidden" class="isFancy" />
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2018/08/10/hello-world/">Hello World</a>
    </h1>
  

      </header>
      
    
    <div class="article-entry" itemprop="articleBody">
      
T
TRHX 已提交
500
          
T
TRHX 已提交
501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521
        <p>Welcome to <a href="https://hexo.io/" target="_blank" rel="noopener">Hexo</a>! This is your very first post. Check <a href="https://hexo.io/docs/" target="_blank" rel="noopener">documentation</a> for more info. If you get any problems when using Hexo, you can find the answer in <a href="https://hexo.io/docs/troubleshooting.html" target="_blank" rel="noopener">troubleshooting</a> or you can ask me on <a href="https://github.com/hexojs/hexo/issues" target="_blank" rel="noopener">GitHub</a>.</p>
<h2 id="Quick-Start"><a href="#Quick-Start" class="headerlink" title="Quick Start"></a>Quick Start</h2><h3 id="Create-a-new-post"><a href="#Create-a-new-post" class="headerlink" title="Create a new post"></a>Create a new post</h3><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 new <span class="string">"My New Post"</span></span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/writing.html" target="_blank" rel="noopener">Writing</a></p>
<h3 id="Run-server"><a href="#Run-server" class="headerlink" title="Run server"></a>Run server</h3><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><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/server.html" target="_blank" rel="noopener">Server</a></p>
<h3 id="Generate-static-files"><a href="#Generate-static-files" class="headerlink" title="Generate static files"></a>Generate static files</h3><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><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/generating.html" target="_blank" rel="noopener">Generating</a></p>
<h3 id="Deploy-to-remote-sites"><a href="#Deploy-to-remote-sites" class="headerlink" title="Deploy to remote sites"></a>Deploy to remote sites</h3><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><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/deployment.html" target="_blank" rel="noopener">Deployment</a></p>

      
      
    </div>
    
    <div class="article-info article-info-index">
      
      

      
      
      <div class="clearfix"></div>
T
TRHX 已提交
522
    </div>
T
TRHX 已提交
523
    
T
TRHX 已提交
524
  </div>
T
TRHX 已提交
525 526
  
</article>
T
TRHX 已提交
527 528 529



T
TRHX 已提交
530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569






  
  
</div>
      <footer id="footer">
    <div class="outer">
        <div id="footer-info">
            <div class="footer-left">
                &copy; 2018 TRHX
            </div>
            <div class="footer-right">
                <a href="http://hexo.io/" target="_blank">Hexo</a>  Theme <a href="https://github.com/luuman/hexo-theme-spfk" target="_blank">spfk</a> by luuman
            </div>
        </div>
        
            <div class="visit">
                
                    <span id="busuanzi_container_site_pv" style='display:none'>
                        <span id="site-visit" >海贼到访数: 
                            <span id="busuanzi_value_site_uv"></span>
                        </span>
                    </span>
                
                
                    <span>, </span>
                
                
                    <span id="busuanzi_container_page_pv" style='display:none'>
                        <span id="page-visit">本页阅读量: 
                            <span id="busuanzi_value_page_pv"></span>
                        </span>
                    </span>
                
            </div>
        
T
TRHX 已提交
570 571
    </div>
</footer>
T
TRHX 已提交
572

T
TRHX 已提交
573 574 575 576 577 578 579 580 581 582 583 584 585 586
    </div>
    <script src="https://7.url.cn/edu/jslib/comb/require-2.1.6,jquery-1.9.1.min.js"></script>
<script src="/js/main.js"></script>

    <script>
        $(document).ready(function() {
            var backgroundnum = 24;
            var backgroundimg = "url(/background/bg-x.jpg)".replace(/x/gi, Math.ceil(Math.random() * backgroundnum));
            $("#mobile-nav").css({"background-image": backgroundimg,"background-size": "cover","background-position": "center"});
            $(".left-col").css({"background-image": backgroundimg,"background-size": "cover","background-position": "center"});
        })
    </script>


T
TRHX 已提交
587

T
TRHX 已提交
588 589 590 591 592 593 594


<div class="scroll" id="scroll">
    <a href="#"><i class="fa fa-arrow-up"></i></a>
    <a href="#comments"><i class="fa fa-comments-o"></i></a>
    <a href="#footer"><i class="fa fa-arrow-down"></i></a>
</div>
T
TRHX 已提交
595
<script>
T
TRHX 已提交
596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628
    $(document).ready(function() {
        if ($("#comments").length < 1) {
            $("#scroll > a:nth-child(2)").hide();
        };
    })
</script>

<script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js">
</script>

  <script language="javascript">
    $(function() {
        $("a[title]").each(function() {
            var a = $(this);
            var title = a.attr('title');
            if (title == undefined || title == "") return;
            a.data('title', title).removeAttr('title').hover(

            function() {
                var offset = a.offset();
                $("<div id=\"anchortitlecontainer\"></div>").appendTo($("body")).html(title).css({
                    top: offset.top - a.outerHeight() - 15,
                    left: offset.left + a.outerWidth()/2 + 1
                }).fadeIn(function() {
                    var pop = $(this);
                    setTimeout(function() {
                        pop.remove();
                    }, pop.text().length * 800);
                });
            }, function() {
                $("#anchortitlecontainer").remove();
            });
        });
T
TRHX 已提交
629 630
    });
</script>
T
TRHX 已提交
631 632


T
TRHX 已提交
633 634 635
  </div>
</body>
</html>