-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
955 lines (399 loc) · 59.2 KB
/
index.html
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
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
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
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
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
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
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
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
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
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
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
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
681
682
683
684
685
686
687
688
689
690
691
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
734
735
736
737
738
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
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
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
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
<!DOCTYPE html>
<html class="theme-next muse use-motion" lang="">
<head>
<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" />
<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 property="og:type" content="website">
<meta property="og:title" content="Hexo">
<meta property="og:url" content="http://yoursite.com/index.html">
<meta property="og:site_name" content="Hexo">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Hexo">
<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>Hexo</title>
</head>
<body itemscope itemtype="http://schema.org/WebPage" lang="">
<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">Hexo</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">
<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 />
Startseite
</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 />
Archiv
</a>
</li>
</ul>
</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">
<article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
<div class="post-block">
<link itemprop="mainEntityOfPage" href="http://yoursite.com/2018/03/09/hexo-github搭建个人blog/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="name" content="John Doe">
<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="Hexo">
</span>
<header class="post-header">
<h1 class="post-title" itemprop="name headline">
<a class="post-title-link" href="/2018/03/09/hexo-github搭建个人blog/" itemprop="url">hexo+github搭建个人blog</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">Veröffentlicht am</span>
<time title="Post created" itemprop="dateCreated datePublished" datetime="2018-03-09T13:45:28+08:00">
2018-03-09
</time>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<p>hexo是一个台湾人做的基于Node.js的静态博客程序,优势是生成静态文件的速度非常快,支持markdown, 我最终选定它的原因是它速度快而且不容易出错,并且可以一键部署到github或者其它静态服务器上去。</p>
<h2 id="安装"><a href="#安装" class="headerlink" title="安装"></a><a href="#安装" title="安装"></a>安装</h2><p>我这个教程hexo3版本,本地使用Windows10系统,在sublime Text上面写Markdown的博客,爽歪歪。</p>
<h3 id="安装依赖软件"><a href="#安装依赖软件" class="headerlink" title="安装依赖软件"></a><a href="#安装依赖软件" title="安装依赖软件"></a>安装依赖软件</h3><p><a href="https://nodejs.org/en" target="_blank" rel="noopener">Node.js</a>: node.js用来创建hexo博客框架的</p>
<p>如果是windows系统,可以直接下载安装文件安装。如果是linux系统,可以使用下面的命令行:</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></pre></td><td class="code"><pre><span class="line">wget <a href="https://nodejs.org/dist/v6.10.0/node-v6.10.0.tar.gz" target="_blank" rel="noopener">https://nodejs.org/dist/v6.10.0/node-v6.10.0.tar.gz</a></span><br><span class="line">tar xzvf node-v<em> && cd node-v</em></span><br><span class="line">yum install gcc gcc-c++</span><br><span class="line">./configure –prefix=/usr/local/nodejs</span><br><span class="line">make && make install #这步时间很久20分钟</span><br><span class="line">node –version # 如果命令找不到就将/usr/local/nodejs/bin加入PATH中</span><br></pre></td></tr></table></figure>
<p>最新的node.js已经集成了npm,不过需要经常更新:</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">npm install npm@latest -g</span><br><span class="line">npm –version</span><br></pre></td></tr></table></figure>
<h3 id="换淘宝源"><a href="#换淘宝源" class="headerlink" title="换淘宝源"></a><a href="#换淘宝源" title="换淘宝源"></a>换淘宝源</h3><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 -g cnpm –registry=<a href="https://registry.npm.taobao.org" target="_blank" rel="noopener">https://registry.npm.taobao.org</a></span><br></pre></td></tr></table></figure>
<p>之后使用cnpm命令代替npm命令,或者你直接通过添加 npm 参数 alias 一个新命令:</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></pre></td><td class="code"><pre><span class="line">alias cnpm="npm –registry=<a href="https://registry.npm.taobao.org" target="_blank" rel="noopener">https://registry.npm.taobao.org</a> \</span><br><span class="line">–cache=$HOME/.npm/.cache/cnpm \</span><br><span class="line">–disturl=<a href="https://npm.taobao.org/dist" target="_blank" rel="noopener">https://npm.taobao.org/dist</a> \</span><br><span class="line">–userconfig=$HOME/.cnpmrc"</span><br></pre></td></tr></table></figure>
<p>安装<a href="http://git-scm.com/download/win" target="_blank" rel="noopener">Git客户端</a>: 把本地的hexo内容提交到github上去</p>
<h3 id="安装hexo"><a href="#安装hexo" class="headerlink" title="安装hexo"></a><a href="#安装hexo" title="安装hexo"></a>安装hexo</h3><p>利用 npm 命令即可安装。打开窗口控制台,输入安装hexo命令:</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">cnpm install -g hexo</span><br></pre></td></tr></table></figure>
<h3 id="初始化"><a href="#初始化" class="headerlink" title="初始化"></a><a href="#初始化" title="初始化"></a>初始化</h3><p>安装完成后,在你喜爱的文件夹下(如D:\Work\hexo),控制台执行以下指令,hexo会自动在目标文件夹建立网站所需要的所有文件。</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 init</span><br></pre></td></tr></table></figure>
<p>安装依赖包:</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">cnpm install</span><br></pre></td></tr></table></figure>
<p>验证下,在D:\Work\hexo内执行以下命令:</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">hexo g #用于生成静态文件</span><br><span class="line">hexo s #用于启动本地服务进行测试</span><br></pre></td></tr></table></figure>
<p>然后用浏览器访问<a href="http://localhost:4000," target="_blank" rel="noopener">http://localhost:4000,</a> 此时,你应该看到了一个漂亮的博客了,当然这个博客只是在本地的,别人是看不到的,hexo3.0使用的默认主题是landscape。</p>
<h2 id="部署到github上面"><a href="#部署到github上面" class="headerlink" title="部署到github上面"></a><a href="#发布到github上面" title="发布到github上面"></a>部署到github上面</h2><p>在github网站(<a href="https://github.com/" target="_blank" rel="noopener">https://github.com/</a> )申请一个账号。</p>
<h3 id="创建repository"><a href="#创建repository" class="headerlink" title="创建repository"></a><a href="#创建repository" title="创建repository"></a>创建repository</h3><p>repository相当于一个仓库,用来放置你的代码文件。登陆进入Github,进入个人页面,选择repositories,然后New一个repository。<br>创建时,只需要填写Repository name(格式必须为yourname.github.io)即可。格式必须为yourname.github.io,比如我的是tanjh.github.io</p>
<h3 id="将本地博客部署上去"><a href="#将本地博客部署上去" class="headerlink" title="将本地博客部署上去"></a><a href="#将本地博客部署上去" title="将本地博客部署上去"></a>将本地博客部署上去</h3><p>github就是一个服务器而已,如果更换了服务器,只需要在更换后的服务器上创建一个git服务,然后将配置文件中的repository修改为新git服务器地址即可。</p>
<h4 id="hexo配置"><a href="#hexo配置" class="headerlink" title="hexo配置"></a><a href="#hexo配置" title="hexo配置"></a>hexo配置</h4><p>先修改D:\Work\hexo中的_config.yml文件,切记:hexo的配置文件中任何’:’后面都是带一个空格的</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></pre></td><td class="code"><pre><span class="line">deploy:</span><br><span class="line"> type: git</span><br><span class="line"> repository: <a href="mailto:git@github.com" target="_blank" rel="noopener">git@github.com</a>:tanjh/tanjh.github.io.git</span><br><span class="line"> branch: master</span><br></pre></td></tr></table></figure>
<h4 id="hexo-git发布模块配置"><a href="#hexo-git发布模块配置" class="headerlink" title="hexo git发布模块配置"></a><a href="#hexo git发布模块配置" title="hexo git发布模块配置"></a>hexo git发布模块配置</h4><p>安装hexo-deployer-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>
<h4 id="SSH配置"><a href="#SSH配置" class="headerlink" title="SSH配置"></a><a href="#SSH配置" title="SSH配置"></a>SSH配置</h4><p>如果你是第一次使用Github或者是已经使用过,但没有配置过SSH,则可能需要配置一下SSH。<br>在Git Bash输入以下指令(任意位置点击鼠标右键),检查是否已经存在了SSH keys。</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">ls -al ~/.ssh</span><br></pre></td></tr></table></figure>
<p>如果存在的话,直接删除.ssh文件夹里面所有文件</p>
<p>输入以下指令(邮箱就是你注册Github时候的邮箱)后回车,出现提示让你输入的时候一直按回车:</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">“<a href="mailto:xxxxx@qq.com" target="_blank" rel="noopener">xxxxx@qq.com</a>“</span></span><br></pre></td></tr></table></figure>
<p>然后键入以下指令:</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">eval</span> <code>ssh-agent -s</code></span><br><span class="line">ssh-add</span><br></pre></td></tr></table></figure>
<p>到了这一步,就可以添加SSH key到你的Github账户了。键入以下指令,拷贝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">clip < ~/.ssh/id_rsa.pub</span><br></pre></td></tr></table></figure>
<p>然后到Github网站中,点击右上角的设置图标Settings,找到SSH keys,Ttile随便你命名,Key就黏贴上你刚才复制的key,然后点Add SSH key,最后会让你重新输入下gitHub的密码<br>最后还是测试一下吧,键入以下命令:</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 <a href="mailto:git@github.com" target="_blank" rel="noopener">git@github.com</a></span><br></pre></td></tr></table></figure>
<p>你可能会看到有警告,输入“yes”就好</p>
<h4 id="发布到github"><a href="#发布到github" class="headerlink" title="发布到github"></a><a href="#发布到github" title="发布到github"></a>发布到github</h4><p>执行以下命令部署到Github上。</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">hexo g</span><br><span class="line">hexo d</span><br></pre></td></tr></table></figure>
<p>提示输入gitHub的账号密码,就能访问你得博客网站了。我的是: tanjh.github.io</p>
<h2 id="发表一篇文章"><a href="#发表一篇文章" class="headerlink" title="发表一篇文章"></a><a href="#发表一篇文章" title="发表一篇文章"></a>发表一篇文章</h2><p>在D:\Work\hexo目录下面,控制台执行命令:</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 new <span class="string">“Hello World”</span></span><br></pre></td></tr></table></figure>
<p>会自动在D:\Work\hexo\source_posts文件夹生成一个hello-world.md文件,用编辑器打开,在里面写文章。<br>记住hexo中写文章使用的是Markdown语法,自己去google下这个语法吧,很方便很强大。里面的初始内容</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></pre></td><td class="code"><pre><span class="line">title: Hello World #可以改成中文的,如“新文章”</span><br><span class="line">date: 2016-03-06 16:04:09 #发表日期,一般不改动</span><br><span class="line">categories: blog #文章文类</span><br><span class="line">tags: [文章, 测试] #文章标签,多于一项时用这种格式,只有一项时使用tags: blog</span><br><span class="line">—</span><br><span class="line">#这里是正文,用markdown写,你可以选择写一段显示在首页的简介后,加上</span><br><span class="line"><!–more–>,在<!–more–>之前的内容会显示在首页,之后的内容会被隐藏,当游客点击Read more才能看到。</span><br></pre></td></tr></table></figure>
<p>写完文章后,你可以使用<code>hexo g</code>生成静态文件。<code>hexo s</code>在本地预览效果。<code>hexo d</code>同步到github</p>
<h2 id="hexo主题及其配置"><a href="#hexo主题及其配置" class="headerlink" title="hexo主题及其配置"></a><a href="#hexo主题及其配置" title="hexo主题及其配置"></a>hexo主题及其配置</h2><p>如果你不喜欢默认主题,那么可以去hexo官网找更多的<a href="https://hexo.io/themes/" target="_blank" rel="noopener">主题</a>。<br>我这里选择NexT主题说明一下,这个是一个非常简洁的主题。</p>
<p>Next主题官网:<a href="http://theme-next.iissnan.com/" target="_blank" rel="noopener">http://theme-next.iissnan.com/</a></p>
<h3 id="安装主题"><a href="#安装主题" class="headerlink" title="安装主题"></a><a href="#安装主题" title="安装主题"></a>安装主题</h3><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> D:\Work\hexo</span><br><span class="line">$ git <span class="built_in">clone</span> <a href="https://github.com/iissnan/hexo-theme-next" target="_blank" rel="noopener">https://github.com/iissnan/hexo-theme-next</a> themes/next</span><br></pre></td></tr></table></figure>
<h3 id="启用主题"><a href="#启用主题" class="headerlink" title="启用主题"></a><a href="#启用主题" title="启用主题"></a>启用主题</h3><p>修改D:\Work\hexo下的_config.yml配置文件中的theme属性,将其设置为next</p>
<h3 id="更新主题"><a href="#更新主题" class="headerlink" title="更新主题"></a><a href="#更新主题" title="更新主题"></a>更新主题</h3><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> themes/next</span><br><span class="line">git pull</span><br></pre></td></tr></table></figure>
<p>更新好后,本地启动起来效果</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 server -g <span class="comment">#生成加预览</span></span><br></pre></td></tr></table></figure>
<h3 id="主题的-config-yml配置"><a href="#主题的-config-yml配置" class="headerlink" title="主题的_config.yml配置"></a><a href="#主题的-config-yml配置" title="主题的_config.yml配置"></a>主题的_config.yml配置</h3><p>具体配置请直接参考<a href="http://theme-next.iissnan.com/getting-started.html" target="_blank" rel="noopener">开始使用NexT主题</a>。</p>
<h3 id="畅言评论"><a href="#畅言评论" class="headerlink" title="畅言评论"></a><a href="#畅言评论" title="畅言评论"></a>畅言评论</h3><p>一开始我用了多说,后来多说关闭不能使用了。然后换到disqus,发现还是有不少问题,首先是https因为不少认证过的,在浏览器里面有警告。<br>另外匿名评论我在管理后台看不到,不知道什么原因。最后还是切换至国内的畅言评论。</p>
<p>参考这篇 <a href="http://www.jianshu.com/p/5888bd91d070" target="_blank" rel="noopener">http://www.jianshu.com/p/5888bd91d070</a></p>
<p>先申请畅言,并且通过审核。获取到畅言评论的<code>APP ID</code> 和<code>APP KEY</code>,复制下来。</p>
<p>主题配置文件<code>_config.yml</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></pre></td><td class="code"><pre><span class="line"># changyan</span><br><span class="line">changyan:</span><br><span class="line"> enable: true</span><br><span class="line"> appid: your_appid</span><br><span class="line"> appkey: your_appkey</span><br></pre></td></tr></table></figure>
<p>安装畅言后遇到几个问题,打开页面控制台后一直报错误,页面循环计数,另外有评论的文章,在首页评论数永远是0,在文章里面计数正常,<br>虽然不影响使用,但是看着真是不舒服。必须解决,参考了一篇文章(后面贴了链接)解决方案。</p>
<p>找到<code>next/layout/_third-party/comments/changyan.swig:1~4行</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></pre></td><td class="code"><pre><span class="line">{% if theme.changyan.enable and theme.changyan.appid and theme.changyan.appkey %}</span><br><span class="line"> {% if is_home() %}</span><br><span class="line"> <script id="cy_cmt_num" src="<a href="https://changyan.sohu.com/upload/plugins/plugins.list.count.js?clientId={{theme.changyan.appid}}"></script" target="_blank" rel="noopener">https://changyan.sohu.com/upload/plugins/plugins.list.count.js?clientId={{theme.changyan.appid}}"></script</a>></span><br><span class="line"> {% else %}</span><br><span class="line"> …省略</span><br></pre></td></tr></table></figure>
<p>只需要将</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">{% else %}</span><br></pre></td></tr></table></figure>
<p>改成</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">{% elseif page.comments %}</span><br></pre></td></tr></table></figure>
<p>然后再找到<code>next/layout/_mavro/post.swig:175~178行</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></pre></td><td class="code"><pre><span class="line"><a href="{{ url_for(post.path) }}#SOHUCS" itemprop="discussionUrl"></span><br><span class="line"> <span id="url::{{ post.permalink }}" class="cy_cmt_count" data-xid="{{ post.path }}" itemprop="commentsCount" ></span></span><br><span class="line"> </a></span><br></pre></td></tr></table></figure>
<p>只需要将<code>post.permalink</code>这个值包一层encodeURI方法,如下修改:</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"><span id="url::{{ encodeURI(post.permalink) }}" class="cy_cmt_count" data-xid="{{ post.path }}" itemprop="commentsCount" ></span></span><br></pre></td></tr></table></figure>
<p>另外如果部署在自己服务器上面的话,你可以在带www的文章下评论完,然后去不带www的文章下看看,评论已经不存在,我做了nginx 301重定向解决。</p>
<h2 id="添加网站的RSS订阅"><a href="#添加网站的RSS订阅" class="headerlink" title="添加网站的RSS订阅"></a><a href="#添加网站的RSS订阅" title="添加网站的RSS订阅"></a>添加网站的RSS订阅</h2><h3 id="安装hexo-generator-feed"><a href="#安装hexo-generator-feed" class="headerlink" title="安装hexo-generator-feed"></a><a href="#安装hexo-generator-feed" title="安装hexo-generator-feed"></a>安装hexo-generator-feed</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">cnpm install hexo-generator-feed –save</span><br></pre></td></tr></table></figure>
<p>安装完后,会在node_modules目录下生成hexo-generator-feed目录</p>
<h3 id="配置根目录的-config-yml"><a href="#配置根目录的-config-yml" class="headerlink" title="配置根目录的_config.yml"></a><a href="#配置根目录的-config-yml" title="配置根目录的_config.yml"></a>配置根目录的_config.yml</h3><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><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"># Extensions</span><br><span class="line">## Plugins: <a href="http://hexo.io/plugins/" target="_blank" rel="noopener">http://hexo.io/plugins/</a></span><br><span class="line">#RSS订阅</span><br><span class="line">plugin:</span><br><span class="line">- hexo-generator-feed</span><br><span class="line">#Feed Atom</span><br><span class="line">feed:</span><br><span class="line"> type: atom</span><br><span class="line"> path: atom.xml</span><br><span class="line"> limit: 20</span><br><span class="line"> hub:</span><br></pre></td></tr></table></figure>
<p>其中,feed是可选项,可配可不配!然后根据各个主题的说明添加一个RSS订阅链接即可</p>
<h2 id="自定义分页"><a href="#自定义分页" class="headerlink" title="自定义分页"></a><a href="#自定义分页" title="自定义分页"></a>自定义分页</h2><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></pre></td><td class="code"><pre><span class="line">npm install hexo-generator-archive –save</span><br><span class="line">npm install hexo-generator-tag –save</span><br><span class="line">npm install hexo-generator-category –save</span><br></pre></td></tr></table></figure>
<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><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">archive_generator:</span><br><span class="line"> per_page: 100</span><br><span class="line"> yearly: true</span><br><span class="line"> monthly: true</span><br><span class="line"> daily: false</span><br><span class="line">tag_generator:</span><br><span class="line"> per_page: 100</span><br><span class="line">category_generator:</span><br><span class="line"> per_page: 100</span><br></pre></td></tr></table></figure>
<h2 id="绑定自己的域名"><a href="#绑定自己的域名" class="headerlink" title="绑定自己的域名"></a><a href="#绑定自己的域名" title="绑定自己的域名"></a>绑定自己的域名</h2><p>Github Page绑定自己域名,在source/目录下面新建<code>CNAME</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"><a href="http://www.pycoding.com" target="_blank" rel="noopener">www.pycoding.com</a></span><br></pre></td></tr></table></figure>
<p>去自己的域名运营商处添加CNAME类型的DNS记录:</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">CNAME: @ => yidao620c.github.io</span><br><span class="line">CNAME: www => yidao620c.github.io</span><br></pre></td></tr></table></figure>
<p>如果是DNSPod,那么后面多加个点</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">@,CNAME,cmback.github.io.</span><br><span class="line">www,CNAME,cmback.github.io.</span><br></pre></td></tr></table></figure>
<h2 id="站内搜索"><a href="#站内搜索" class="headerlink" title="站内搜索"></a><a href="#站内搜索" title="站内搜索"></a>站内搜索</h2><p>最简单是直接开启<code>Local Search</code></p>
<p>安装 <code>hexo-generator-searchdb</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">cnpm install hexo-generator-searchdb –save</span><br></pre></td></tr></table></figure>
<p>全局配置文件_config.yml中定义搜索页面:</p>
<figure class="highlight html"><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">search:</span><br><span class="line"> path: search.xml</span><br><span class="line"> field: post</span><br><span class="line"> format: html</span><br><span class="line"> limit: 10000</span><br></pre></td></tr></table></figure>
<p>在NexT的_config.yml配置中开启这个本地搜索:</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"># Local search</span><br><span class="line">local_search:</span><br><span class="line"> enable: true</span><br></pre></td></tr></table></figure>
<h2 id="algolia搜索"><a href="#algolia搜索" class="headerlink" title="algolia搜索"></a><a href="#algolia搜索" title="algolia搜索"></a>algolia搜索</h2><p>使用一段时间的<code>Local Search</code>后发现还是不太好用,后来比较了一下Swiftype、 微搜索、Local Search 和 Algolia,<br>发现<code>algolia</code>比较好。安装<code>NexT</code>文档配置步骤如下:</p>
<p>第一步,先注册Algolia,创建Index</p>
<p>前往 <a href="https://www.algolia.com/" target="_blank" rel="noopener">Algolia 注册页面</a>,注册一个新账户。可以使用 GitHub 或者 Google 账户直接登录,<br>注册后的 14 天内拥有所有功能(包括收费类别的)。之后若未续费会自动降级为免费账户,免费账户总共有 10,000 条记录,<br>每月有 100,000 的可以操作数。注册完成后,创建一个新的 Index,这个 Index 将在后面使用。</p>
<p>第二步,安装Algolia</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 –save hexo-algolia</span><br></pre></td></tr></table></figure>
<p>第三步,获取Key,更新站点配置</p>
<p>在 Algolia 服务站点上找到需要使用的一些配置的值,包括 <code>ApplicationID</code>、<code>Search-Only API Key</code>、<code>min API Key</code>。<br>注意,Admin API Key 需要保密保存。点击ALL API KEYS 找到新建INDEX对应的key, 编辑权限,<br>在弹出框中找到ACL选择勾选<code>Search</code>、<code>Add records</code>、<code>Delete records</code>、<code>List indices</code>、<code>Delete index</code>权限,点击update更新。</p>
<p><img src="https://xnstatic-1253397658.file.myqcloud.com/hexo20.png" alt=""></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></pre></td><td class="code"><pre><span class="line">algolia:</span><br><span class="line"> applicationID: 'IQUD4IM8MM'</span><br><span class="line"> indexName: 'blogindex'</span><br><span class="line"> chunkSize: 5000</span><br></pre></td></tr></table></figure>
<p>替换除了 chunkSize 以外的其他字段为在 Algolia 获取到的值。</p>
<p>第四步,更新Index</p>
<p>当配置完成,新增一个环境变量,windwos和linux配置环境变量我就不讲了。</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">HEXO_ALGOLIA_INDEXING_KEY=Search-Only API key</span><br></pre></td></tr></table></figure>
<p>在站点根目录下执行</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">$ hexo algolia</span><br></pre></td></tr></table></figure>
<p>来更新 Index,请注意观察命令的输出。</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></pre></td><td class="code"><pre><span class="line">$ hexo algolia</span><br><span class="line">INFO [Algolia] Testing HEXO_ALGOLIA_INDEXING_KEY permissions.</span><br><span class="line">INFO Start processing</span><br><span class="line">INFO [Algolia] Identified 152 pages and posts to index.</span><br><span class="line">INFO [Algolia] Indexing chunk 1 of 4 (50 items each)</span><br><span class="line">INFO [Algolia] Indexing chunk 2 of 4 (50 items each)</span><br><span class="line">INFO [Algolia] Indexing chunk 3 of 4 (50 items each)</span><br><span class="line">INFO [Algolia] Indexing chunk 4 of 4 (50 items each)</span><br><span class="line">INFO [Algolia] Indexing done.</span><br></pre></td></tr></table></figure>
<p>注意,每次更新文章后记得执行<code>hexo algolia</code>更新索引哦。</p>
<p>第五步,主题集成</p>
<p>更改主题配置文件,找到 Algolia Search 配置部分:</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></pre></td><td class="code"><pre><span class="line"># Algolia Search</span><br><span class="line">algolia_search:</span><br><span class="line"> enable: false</span><br><span class="line"> hits:</span><br><span class="line"> per_page: 10</span><br><span class="line"> labels:</span><br><span class="line"> input_placeholder: Search for Posts</span><br><span class="line"> hits_empty: "We didn't find any results for the search: ${query}"</span><br><span class="line"> hits_stats: "${hits} results found in ${time} ms"</span><br></pre></td></tr></table></figure>
<p>将 <code>enable</code> 改为 <code>true</code> 即可,根据需要你可以调整 <code>labels</code> 中的文本。</p>
<h2 id="阅读次数统计"><a href="#阅读次数统计" class="headerlink" title="阅读次数统计"></a><a href="#阅读次数统计" title="阅读次数统计"></a>阅读次数统计</h2><p>使用LeanCloud为文章添加阅读次数统计,请参考文章<a href="https://notes.wanghao.work/2015-10-21-%E4%B8%BANexT%E4%B8%BB%E9%A2%98%E6%B7%BB%E5%8A%A0%E6%96%87%E7%AB%A0%E9%98%85%E8%AF%BB%E9%87%8F%E7%BB%9F%E8%AE%A1%E5%8A%9F%E8%83%BD.html#%E9%85%8D%E7%BD%AELeanCloud" target="_blank" rel="noopener">为NexT主题添加文章阅读量统计功能</a></p>
<h2 id="多台电脑同时维护博客"><a href="#多台电脑同时维护博客" class="headerlink" title="多台电脑同时维护博客"></a><a href="#多台电脑同时维护博客" title="多台电脑同时维护博客"></a>多台电脑同时维护博客</h2><p>之前利用了 Hexo + Github搭建了自己的博客网站,但问题来了:如何在多台电脑上对此博客进行维护?</p>
<h3 id="思路"><a href="#思路" class="headerlink" title="思路"></a><a href="#思路" title="思路"></a>思路</h3><ul>
<li>对于一个已创建的博客目录,其已通过hexo建立了public目录下的内容与远程仓库<a href="mailto:yidao620c@github.com" target="_blank" rel="noopener">yidao620c@github.com</a>的master分支的连接关系,通过hexo的hexo deploy命令即可保持更新;</li>
<li>因此只需要在此仓库<a href="mailto:yidao620c@github.com" target="_blank" rel="noopener">yidao620c@github.com</a>上再创建一个分支如source,将其与hexo下其他文件如node_modules、themes、scaffolds等(即除了public目录及.gitignore包含的文件外)进行同步绑定。</li>
<li>在不同的电脑下设置好hexo环境,通过hexo命令维护master分支,通过git命令维护source分支即可。</li>
</ul>
<h3 id="具体步骤"><a href="#具体步骤" class="headerlink" title="具体步骤"></a><a href="#具体步骤" title="具体步骤"></a>具体步骤</h3><p>(假定最初创建博客为A,其他另一个为B)</p>
<p>1) 在A中的git_blog目录下,建立source分支:</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></pre></td><td class="code"><pre><span class="line">$ git branch <span class="built_in">source</span> // 创建<span class="built_in">source</span>分支</span><br><span class="line">$ git checkout <span class="built_in">source</span> // 切换到<span class="built_in">source</span>分支</span><br><span class="line">$ git remote -v //查看远程分支名字</span><br><span class="line"> // 我的内容为如下,说明已绑定</span><br><span class="line"> // origin <a href="mailto:git@github.com" target="_blank" rel="noopener">git@github.com</a>:yidao620c/yidao620c.github.com.git (fetch)</span><br><span class="line"> // origin <a href="mailto:git@github.com" target="_blank" rel="noopener">git@github.com</a>:yidao620c/yidao620c.github.com.git (push)</span><br><span class="line">修改.gitignore文件,添加<span class="string">“public/“</span>字段至其中。</span><br><span class="line">$ git push origin <span class="built_in">source</span> // 将当前git_blog下的内容push到Github上的远程仓库的<span class="built_in">source</span>分支(会自动创建)上</span><br></pre></td></tr></table></figure>
<p>2) 在B中建立git_blog目录,安装npm,安装Hexo,添加SSH,然后在B中建立本地的source分支,并与远程的source分支进行了绑定。<br>git_blog下的yidao620c.github.com文件夹里保存了和远程source分支相同的内容。</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></pre></td><td class="code"><pre><span class="line">$ git <span class="built_in">clone</span> -b <span class="built_in">source</span> <a href="mailto:git@github.com" target="_blank" rel="noopener">git@github.com</a>:yidao620c/yidao620c.github.com.git</span><br><span class="line">$ <span class="built_in">cd</span> yidao620c.github.com</span><br><span class="line">$ git branch -a</span><br><span class="line">$ git checkout -b <span class="built_in">source</span> origin/<span class="built_in">source</span></span><br><span class="line">$ cnpm install hexo</span><br><span class="line">$ cnpm install</span><br><span class="line">$ cnpm install hexo-deployer-git –save</span><br><span class="line">$ cnpm install hexo-renderer-jade –save</span><br><span class="line">$ cnpm install hexo-renderer-sass –save</span><br></pre></td></tr></table></figure>
<p><strong>重要记录</strong></p>
<p>千万别执行<code>hexo init</code>这个命令啊,同时<code>Next</code>主题的安装步骤还是需要的。</p>
<p>另外hexo3.4.3版本好像生成toc的时候有点问题,我退回到3.3.9就正常。</p>
<p>首先<code>package.json</code>改成绝对版本号:</p>
<figure class="highlight json"><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><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br></pre></td><td class="code"><pre><span class="line">{</span><br><span class="line"> <span class="attr">“name”</span>: <span class="string">“hexo-site”</span>,</span><br><span class="line"> <span class="attr">“version”</span>: <span class="string">“0.0.0”</span>,</span><br><span class="line"> <span class="attr">“private”</span>: <span class="literal">true</span>,</span><br><span class="line"> <span class="attr">“hexo”</span>: {</span><br><span class="line"> <span class="attr">“version”</span>: <span class="string">“3.3.9”</span></span><br><span class="line"> },</span><br><span class="line"> <span class="attr">“dependencies”</span>: {</span><br><span class="line"> <span class="attr">“hexo”</span>: <span class="string">“3.3.9”</span>,</span><br><span class="line"> <span class="attr">“hexo-algolia”</span>: <span class="string">“^1.2.3”</span>,</span><br><span class="line"> <span class="attr">“hexo-deployer-git”</span>: <span class="string">“^0.3.1”</span>,</span><br><span class="line"> <span class="attr">“hexo-generator-archive”</span>: <span class="string">“^0.1.5”</span>,</span><br><span class="line"> <span class="attr">“hexo-generator-category”</span>: <span class="string">“^0.1.3”</span>,</span><br><span class="line"> <span class="attr">“hexo-generator-feed”</span>: <span class="string">“^1.2.2”</span>,</span><br><span class="line"> <span class="attr">“hexo-generator-index”</span>: <span class="string">“^0.2.0”</span>,</span><br><span class="line"> <span class="attr">“hexo-generator-searchdb”</span>: <span class="string">“^1.0.8”</span>,</span><br><span class="line"> <span class="attr">“hexo-generator-tag”</span>: <span class="string">“^0.2.0”</span>,</span><br><span class="line"> <span class="attr">“hexo-renderer-ejs”</span>: <span class="string">“^0.3.0”</span>,</span><br><span class="line"> <span class="attr">“hexo-renderer-jade”</span>: <span class="string">“^0.4.1”</span>,</span><br><span class="line"> <span class="attr">“hexo-renderer-marked”</span>: <span class="string">“^0.3.0”</span>,</span><br><span class="line"> <span class="attr">“hexo-renderer-sass”</span>: <span class="string">“^0.3.2”</span>,</span><br><span class="line"> <span class="attr">“hexo-renderer-stylus”</span>: <span class="string">“^0.3.1”</span>,</span><br><span class="line"> <span class="attr">“hexo-server”</span>: <span class="string">“^0.2.0”</span></span><br><span class="line"> }</span><br><span class="line">}</span><br></pre></td></tr></table></figure>
<p>然后把hexo卸载了,重新安装指定版本,在另外一个目录执行:</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">cnpm uninstall hexo -g</span><br><span class="line">cnpm install <a href="mailto:hexo@3.3.9" target="_blank" rel="noopener">hexo@3.3.9</a> -g</span><br></pre></td></tr></table></figure>
<p>然后再回到hexo目录执行:</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">cnpm install</span><br></pre></td></tr></table></figure>
<h3 id="使用方法"><a href="#使用方法" class="headerlink" title="使用方法"></a><a href="#使用方法" title="使用方法"></a>使用方法</h3><p>如果是新电脑,先把source分支clone下来:</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> -b <span class="built_in">source</span> –single-branch <a href="https://github.com/yidao620c/yidao620c.github.io.git" target="_blank" rel="noopener">https://github.com/yidao620c/yidao620c.github.io.git</a></span><br></pre></td></tr></table></figure>
<p>在任意一台mac操作,都需先切换并保持在source分支上。使用git命令管理source文件;使用hexo命令进行同步至远程master分支,无需处理本地master分支</p>
<ol>
<li>在A中使用Hexo的new、g、d方法添加、生成、部署新的博客,内容都会被同步自动放到Github的master分支上</li>
<li>在A中使用git命令的<code>push origin source</code>同步source到远程source分支</li>
<li>同样保证B的git当前在git_blog下的source分支下</li>
</ol>
<p>先使用:</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 pull origin <span class="built_in">source</span></span><br></pre></td></tr></table></figure>
<p>获得Github的source分支上的最新版本,再使用:</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></pre></td><td class="code"><pre><span class="line">$ git add -u</span><br><span class="line">$ git commit -m <span class="string">“”</span></span><br><span class="line">$ git push origin <span class="built_in">source</span></span><br></pre></td></tr></table></figure>
<p>将新内容提交至Github的source分支上,完成source管理。</p>
<h3 id="其他说明"><a href="#其他说明" class="headerlink" title="其他说明"></a><a href="#其他说明" title="其他说明"></a>其他说明</h3><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></pre></td><td class="code"><pre><span class="line">git add -f xxx // 强制添加文件/文件夹为tracked状态</span><br><span class="line">git rm –cache xxx // 解除文件为tracked状态</span><br><span class="line">git rm -r –cache xxx // 解除文件夹为tracked状态</span><br></pre></td></tr></table></figure>
<h2 id="FAQ"><a href="#FAQ" class="headerlink" title="FAQ"></a><a href="#FAQ" title="FAQ"></a>FAQ</h2><ul>
<li>遇到有大括号的代码块,如果多行的不用管,如果单行的就单个反引号,并且在里面加raw标签,比如 <code></code>* 关闭hexo的将回车当换行做法是用正常的markdown两个回车当换行,在全局_config.yml中添加配置<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">marked:</span><br><span class="line"> gfm: true</span><br><span class="line"> breaks: false</span><br></pre></td></tr></table></figure></li>
</ul>
<h2 id="参考"><a href="#参考" class="headerlink" title="参考"></a><a href="#参考" title="参考"></a>参考</h2><ul>
<li><a href="http://tengj.top/tags/hexo/" target="_blank" rel="noopener">hexo干货系列</a></li>
<li><a href="https://www.haomwei.com/technology/maupassant-hexo.html" target="_blank" rel="noopener">大道至简——Hexo简洁主题推荐</a></li>
<li><a href="http://www.chaixuhong.com/article/NEXT%E4%BD%BF%E7%94%A8%E7%95%85%E8%A8%80%E7%9A%84%E9%97%AE%E9%A2%98.html" target="_blank" rel="noopener">NEXT主题中使用畅言的坑</a></li>
</ul>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</div>
</article>
<article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
<div class="post-block">
<link itemprop="mainEntityOfPage" href="http://yoursite.com/2018/03/09/hello-world/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="name" content="John Doe">
<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="Hexo">
</span>
<header class="post-header">
<h1 class="post-title" itemprop="name headline">
<a class="post-title-link" href="/2018/03/09/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">Veröffentlicht am</span>
<time title="Post created" itemprop="dateCreated datePublished" datetime="2018-03-09T12:00:20+08:00">
2018-03-09
</time>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<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>
<footer class="post-footer">
<div class="post-eof"></div>
</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>
</div>
</div>
<aside id="sidebar" class="sidebar">
<div class="sidebar-inner">
<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">John Doe</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">Artikel</span>
</a>
</div>
<div class="site-state-item site-state-tags">
<span class="site-state-item-count">1</span>
<span class="site-state-item-name">Tags</span>
</div>
</nav>
</div>
</section>
</div>
</aside>
</div>
</main>
<footer id="footer" class="footer">
<div class="footer-inner">
<div class="copyright">© <span itemprop="copyrightYear">2018</span>
<span class="with-love">
<i class="fa fa-user"></i>
</span>
<span class="author" itemprop="copyrightHolder">John Doe</span>
</div>
<div class="powered-by">Erstellt mit <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a></div>
<span class="post-meta-divider">|</span>
<div class="theme-info">Theme — <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>
</div>
<script type="text/javascript">
if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
window.Promise = null;
}
</script>
<script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>
<script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
<script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
<script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
<script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
<script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
<script type="text/javascript" src="/js/src/utils.js?v=5.1.4"></script>
<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>
</body>
</html>