index.html 38.6 KB
Newer Older
T
TRHX 已提交
1
<!DOCTYPE html>
T
TRHX 已提交
2 3 4 5 6 7 8



  


<html class="theme-next muse use-motion" lang="zh-CN">
T
TRHX 已提交
9
<head>
T
TRHX 已提交
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
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="theme-color" content="#222">









<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
















T
TRHX 已提交
41
  
T
TRHX 已提交
42 43 44 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
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />







<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.4" rel="stylesheet" type="text/css" />


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=5.1.4">


  <link rel="mask-icon" href="/images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="Hexo, NexT" />










<meta name="description" content="一个大学生用于自学的个人博客">
T
TRHX 已提交
83 84 85 86 87 88 89 90 91
<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 已提交
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Muse',
    version: '5.1.4',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: 'Author'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://yoursite.com/"/>





  <title>TRHX'Blog</title>
T
TRHX 已提交
128
  
T
TRHX 已提交
129 130 131 132 133 134 135 136 137 138 139 140








</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-CN">

T
TRHX 已提交
141 142
  
  
T
TRHX 已提交
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176
    
  

  <div class="container sidebar-position-left 
  page-home">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">TRHX'Blog</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle">天下事有难易乎?为之,则难者亦易矣;不为,则易者亦难矣!</p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
T
TRHX 已提交
177
  
T
TRHX 已提交
178

T
TRHX 已提交
179
  
T
TRHX 已提交
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            Home
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            Archives
          </a>
        </li>
      

      
    </ul>
T
TRHX 已提交
205
  
T
TRHX 已提交
206

T
TRHX 已提交
207
  
T
TRHX 已提交
208 209 210 211 212 213 214 215 216 217 218 219 220
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            
  <section id="posts" class="posts-expand">
T
TRHX 已提交
221
    
T
TRHX 已提交
222 223 224 225 226
      

  

  
T
TRHX 已提交
227 228
  
  
T
TRHX 已提交
229

T
TRHX 已提交
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248
  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2018/08/15/如何使用Github Pages和Hexo搭建自己独立博客/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="TRHX">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="TRHX'Blog">
    </span>

    
      <header class="post-header">
T
TRHX 已提交
249 250 251

        
        
T
TRHX 已提交
252 253 254
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2018/08/15/如何使用Github Pages和Hexo搭建自己独立博客/" itemprop="url">如何使用Github Pages和Hexo搭建自己独立博客</a></h1>
T
TRHX 已提交
255
        
T
TRHX 已提交
256

T
TRHX 已提交
257 258 259 260 261 262 263 264 265 266 267 268 269
        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">Posted on</span>
              
              <time title="Post created" itemprop="dateCreated datePublished" datetime="2018-08-15T21:34:58+08:00">
                2018-08-15
              </time>
            
T
TRHX 已提交
270 271

            
T
TRHX 已提交
272

T
TRHX 已提交
273
            
T
TRHX 已提交
274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292
          </span>

          

          
            
          

          
          

          

          

          

        </div>
      </header>
T
TRHX 已提交
293
    
T
TRHX 已提交
294

T
TRHX 已提交
295 296
    
    
T
TRHX 已提交
297 298
    
    <div class="post-body" itemprop="articleBody">
T
TRHX 已提交
299

T
TRHX 已提交
300 301
      
      
T
TRHX 已提交
302 303 304

      
        
T
TRHX 已提交
305
          
T
TRHX 已提交
306
            <center><font color="#000000" size="6" face="楷体"><strong>如何使用Github Pages和Hexo搭建自己独立博客</strong></font></center>
T
TRHX 已提交
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 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 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

<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 已提交
498

T
TRHX 已提交
499 500
          
        
T
TRHX 已提交
501
      
T
TRHX 已提交
502
    </div>
T
TRHX 已提交
503
    
T
TRHX 已提交
504 505 506 507 508 509 510 511 512 513
    
    

    

    

    

    <footer class="post-footer">
T
TRHX 已提交
514
      
T
TRHX 已提交
515

T
TRHX 已提交
516 517 518
      

      
T
TRHX 已提交
519

T
TRHX 已提交
520
      
T
TRHX 已提交
521 522 523 524
      
        <div class="post-eof"></div>
      
    </footer>
T
TRHX 已提交
525
  </div>
T
TRHX 已提交
526
  
T
TRHX 已提交
527 528 529
  
  
  </article>
T
TRHX 已提交
530

T
TRHX 已提交
531

T
TRHX 已提交
532 533
    
      
T
TRHX 已提交
534

T
TRHX 已提交
535
  
T
TRHX 已提交
536

T
TRHX 已提交
537 538 539
  
  
  
T
TRHX 已提交
540

T
TRHX 已提交
541 542 543 544 545 546
  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2018/08/10/hello-world/">
T
TRHX 已提交
547

T
TRHX 已提交
548 549 550 551 552
    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="TRHX">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>
T
TRHX 已提交
553

T
TRHX 已提交
554 555 556
    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="TRHX'Blog">
    </span>
T
TRHX 已提交
557

T
TRHX 已提交
558 559
    
      <header class="post-header">
T
TRHX 已提交
560

T
TRHX 已提交
561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603
        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2018/08/10/hello-world/" itemprop="url">Hello World</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">Posted on</span>
              
              <time title="Post created" itemprop="dateCreated datePublished" datetime="2018-08-10T17:33:18+08:00">
                2018-08-10
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          

          

          

        </div>
      </header>
T
TRHX 已提交
604
    
T
TRHX 已提交
605

T
TRHX 已提交
606 607
    
    
T
TRHX 已提交
608 609
    
    <div class="post-body" itemprop="articleBody">
T
TRHX 已提交
610 611 612

      
      
T
TRHX 已提交
613 614 615

      
        
T
TRHX 已提交
616
          
T
TRHX 已提交
617
            <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>
T
TRHX 已提交
618 619 620 621 622 623 624 625 626
<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>

T
TRHX 已提交
627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648
          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
T
TRHX 已提交
649
      
T
TRHX 已提交
650
        <div class="post-eof"></div>
T
TRHX 已提交
651
      
T
TRHX 已提交
652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680
    </footer>
  </div>
  
  
  
  </article>


    
  </section>

  


          </div>
          


          

        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
T
TRHX 已提交
681
    </div>
T
TRHX 已提交
682 683 684
  </div>

  <aside id="sidebar" class="sidebar">
T
TRHX 已提交
685
    
T
TRHX 已提交
686 687
    <div class="sidebar-inner">

T
TRHX 已提交
688
      
T
TRHX 已提交
689

T
TRHX 已提交
690 691
      

T
TRHX 已提交
692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733
      <section class="site-overview-wrap sidebar-panel sidebar-panel-active">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <p class="site-author-name" itemprop="name">TRHX</p>
              <p class="site-description motion-element" itemprop="description">一个大学生用于自学的个人博客</p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/archives/">
              
                  <span class="site-state-item-count">2</span>
                  <span class="site-state-item-name">posts</span>
                </a>
              </div>
            

            

            

          </nav>

          

          

          
          

          
          

          

        </div>
      </section>

T
TRHX 已提交
734
      
T
TRHX 已提交
735

T
TRHX 已提交
736
      
T
TRHX 已提交
737

T
TRHX 已提交
738
    </div>
T
TRHX 已提交
739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2018</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">TRHX</span>

  
</div>


  <div class="powered-by">Powered by <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a></div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">Theme &mdash; <a class="theme-link" target="_blank" href="https://github.com/iissnan/hexo-theme-next">NexT.Muse</a> v5.1.4</div>




        







        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
T
TRHX 已提交
788
    
T
TRHX 已提交
789 790 791

    

T
TRHX 已提交
792
  </div>
T
TRHX 已提交
793

T
TRHX 已提交
794
  
T
TRHX 已提交
795 796 797 798 799 800

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>
T
TRHX 已提交
801 802 803



T
TRHX 已提交
804 805 806 807 808 809 810






  
T
TRHX 已提交
811 812 813 814 815 816 817 818 819 820 821 822 823 824 825












  
  
    <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>
T
TRHX 已提交
826
  
T
TRHX 已提交
827

T
TRHX 已提交
828 829 830 831
  
  
    <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  
T
TRHX 已提交
832

T
TRHX 已提交
833 834 835 836
  
  
    <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  
T
TRHX 已提交
837

T
TRHX 已提交
838 839 840 841
  
  
    <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  
T
TRHX 已提交
842

T
TRHX 已提交
843 844 845 846
  
  
    <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  
T
TRHX 已提交
847

T
TRHX 已提交
848 849 850 851
  
  
    <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  
T
TRHX 已提交
852 853


T
TRHX 已提交
854
  
T
TRHX 已提交
855 856


T
TRHX 已提交
857
  <script type="text/javascript" src="/js/src/utils.js?v=5.1.4"></script>
T
TRHX 已提交
858

T
TRHX 已提交
859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927
  <script type="text/javascript" src="/js/src/motion.js?v=5.1.4"></script>



  
  

  

  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  












  





  

  

  

  
  

  

  

  
T
TRHX 已提交
928

T
TRHX 已提交
929
</body>
T
TRHX 已提交
930
</html>