开始使用Hexo + Github去搭建一个属于自己的博客站点,可以在这里发布一下自己的想法,一些问题积累,一些发现。

新建文章
hexo new '文章标题'
生成静态网页&部署
hexo clean 清除缓存hexo g 生成静态网页hexo d 开始部署
连接写法:hexo c && hexo g && hexo d
开启评论
1.我使用多说代替自带的评论,在多说 网站注册 > 后台管理 > 添加新站点 > 工具 === 复制通用代码 里面有 short_name
在根目录 _config.yml 添加一行 disqus_shortname: jslite 是在多说注册时产生的
复制到 themes\landscape\layout_partial\article.ejs
把1
2
3
4
5
6
7<% if (!index && post.comments && config.disqus_shortname){ %>
<section id="comments">
<div id="disqus_thread">
<noscript>Please enable JavaScript to view the <a href="//disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
</div>
</section>
<% } %>
改为1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20<% if (!index && post.comments && config.disqus_shortname){ %>
<section id="comments">
<!-- 多说评论框 start -->
<div class="ds-thread" data-thread-key="<%= post.layout %>-<%= post.slug %>" data-title="<%= post.title %>" data-url="<%= page.permalink %>"></div>
<!-- 多说评论框 end -->
<!-- 多说公共JS代码 start (一个网页只需插入一次) -->
<script type="text/javascript">
var duoshuoQuery = {short_name:'<%= config.disqus_shortname %>'};
(function() {
var ds = document.createElement('script');
ds.type = 'text/javascript';ds.async = true;
ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js';
ds.charset = 'UTF-8';
(document.getElementsByTagName('head')[0]
|| document.getElementsByTagName('body')[0]).appendChild(ds);
})();
</script>
<!-- 多说公共JS代码 end -->
</section>
<% } %>
hexo相处里的错误
部署没有权限
1 | [master 74ddc79] Site updated: 2018-07-22 23:14:27 |
查看权限
1 |
|
接下来这样来
1、检查是否有SSH key
- 登陆github,点击头像位置处 Settings ——> SSH and GPG keys ,查看是否有SSH keys。如果有,直接进行第三步。
2、新建 SSH key,在git shell(或者git bash等命令窗口),注意大小写:
ssh-keygen -t rsa -C "邮箱名"
然后会出现: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
30Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/dell/.ssh/id_rsa):
直接回车就可以。
然后会出现:
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
要求你输入密码,这个密码会在你提交项目时使用,如果为空的话提交项目时则不用输入。这个设置是防止别人往你的项目里提交内容。
注意:输入密码的时候没有*字样的,直接输入就好。
然后会出现:
Your identification has been saved in /c/Users/dell/.ssh/id_rsa.
Your public key has been saved in /c/Users/dell/.ssh/id_rsa.pub.
The key fingerprint is:
65:69:······02:4b emailname@email.com
The key's randomart image is:
+--[ RSA 2048]----+
| |
| . o . |
| . o o = o |
| . o * = o |
| E o + o . |
| . o. . . |
| .. |
+-----------------+
至此,密钥已经成功生成。
3、接下来在github上添加SSH key:
① 打开本地文件:id_rsa.pub(文件路径可以在上一步SSH生成成功后看到路径,比如我的是/Users/duanruilong/.ssh/id_rsa.pub),可以将这个文件在编辑器中打开,然后全选复制。
② 登陆github,点击头像位置处 Settings ——> SSH and GPG keys ——> New SSH key,点击新建SSH key。
③ 将 ① 中复制的内容粘贴在key文本框里,title可以不用填(或者自己起一个名字也可以)。
4、测试设置是否成功
ssh -T git@github.com
有可能会出现:
1 |
|
5、设置用户信息
~ git config --global user.name~ git config --global user.email
6、然后就可以部署你的博客
hexo g && hexo d