-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshi-yong-hexo-githubda-jian-blog.html
executable file
·127 lines (105 loc) · 5.06 KB
/
shi-yong-hexo-githubda-jian-blog.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
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="utf-8" />
<title>使用hexo + github搭建blog</title>
<link rel="stylesheet" href="https://bridgeqiao.github.io/blog/theme/css/main.css" />
<!--[if IE]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body id="index" class="home">
<header id="banner" class="body">
<h1><a href="https://bridgeqiao.github.io/blog/">Bridge Qiao's Blog </a></h1>
<nav><ul>
<li><a href="https://bridgeqiao.github.io/blog/category/computer-vision.html">Computer vision</a></li>
<li class="active"><a href="https://bridgeqiao.github.io/blog/category/fun.html">fun</a></li>
<li><a href="https://bridgeqiao.github.io/blog/category/linux.html">linux</a></li>
<li><a href="https://bridgeqiao.github.io/blog/category/machine-learning.html">Machine Learning</a></li>
<li><a href="https://bridgeqiao.github.io/blog/category/matlab.html">Matlab</a></li>
<li><a href="https://bridgeqiao.github.io/blog/category/suan-fa-ti.html">算法题</a></li>
</ul>
</nav>
</header><!-- /#banner -->
<section id="content" class="body">
<article>
<header>
<h1 class="entry-title">
<a href="https://bridgeqiao.github.io/blog/shi-yong-hexo-githubda-jian-blog.html" rel="bookmark"
title="Permalink to 使用hexo + github搭建blog">使用hexo + github搭建blog</a></h1>
</header>
<div class="entry-content">
<footer class="post-info">
<span>日 14 一月 2018</span>
</footer><!-- /.post-info --> <p>最近使用jekyll烦了,经常出现博客编译出问题,打算试下hexo,结果很不错,所以直接换成了hexo,这里写个blog留作记录。</p>
<h4>1. 安装环境</h4>
<p>hexo是本地先编译成功后,再上传到github上,和jekyll不一样(github内部支持)。</p>
<p>这里只介绍linux环境,在windows直接下载软件包安装就行。</p>
<p>安装<code>nodejs</code>, <code>hexo</code>:</p>
<div class="highlight"><pre><span></span>sudo apt install nodejs-legacy
sudo npm install hexo -g
<span class="c1"># 配置git方式部署</span>
sudo npm install hexo-deployer-git --save
</pre></div>
<p>这里可以考虑使用<a href="https://lug.ustc.edu.cn/wiki/mirrors/help/npm">USTC</a>加速下载软件包:</p>
<!--more-->
<div class="highlight"><pre><span></span><span class="c1"># 编辑 ~/.npmrc</span>
<span class="nv">registry</span><span class="o">=</span>http://npmreg.mirrors.ustc.edu.cn/
</pre></div>
<h4>2. 配置环境</h4>
<p>在github上新建项目,xxx.github.io或者blog,其中xxx是你的用户名。</p>
<blockquote>
<p>开启hs-pages功能:在settings里有副标题:GitHub Pages,点击一下Automatic page generator即可。</p>
</blockquote>
<p>新建一个文件夹,命名和项目名相同,然后:</p>
<div class="highlight"><pre><span></span>sudo hexo init
</pre></div>
<p>修改_config.conf,可以参考<a href="https://xuanwo.org/2015/03/26/hexo-intor/">这个网站</a>。</p>
<p>分类可能看不到,解决办法:</p>
<div class="highlight"><pre><span></span>> sudo hexo new page categories
<span class="c1"># 在source/categories/index.md里date下添加:</span>
type: <span class="s2">"categories"</span>
comments: <span class="nb">false</span>
</pre></div>
<h4>3. 添加文章</h4>
<p>在source/_post目录下放置文章,命名titleName.md,</p>
<p>里面的文章开头添加:</p>
<div class="highlight"><pre><span></span>---
title: titleName
date: xxxx-xx-xx
categories: xxxx
---
</pre></div>
<p>可能会需要配置用户信息,user.email和user.name</p>
<p>最后执行:</p>
<div class="highlight"><pre><span></span>sudo hexo g
sudo hexo d
</pre></div>
<p>输入用户名和密码即可。</p>
<hr>
<p>hexo对公式的支持有点问题,需要安装插件:</p>
<div class="highlight"><pre><span></span>sudo npm install hexo-math --save
# 在blog文件夹中执行:
sudo hexo math install
# 在_config.yml中添加:
mathjax: true
</pre></div>
<p>在相应文章的开头添加<code>mathjax: true</code></p>
</div><!-- /.entry-content -->
</article>
</section>
<section id="extras" class="body">
<div class="blogroll">
<h2>blogroll</h2>
<ul>
<li><a href="http://getpelican.com/">Pelican</a></li>
<li><a href="http://python.org/">Python.org</a></li>
<li><a href="https://github.com">Github</a></li>
</ul>
</div><!-- /.blogroll -->
</section><!-- /#extras -->
<footer id="contentinfo" class="body">
<p>Powered by <a href="http://getpelican.com/">Pelican</a>. Theme <a href="https://github.com/blueicefield/pelican-blueidea/">blueidea</a>, inspired by the default theme.</p>
</footer><!-- /#contentinfo -->
</body>
</html>