Site

1
2
3
4
5
6
7
title: TR //网站标题
subtitle: TR's Blog //网站副标题
description: 学习永无止境 //网站描述
keywords: //关键字,便于搜索引擎的搜索
author: TR //您的名字
language: zh-Hans //网站使用的语言
timezone: //网站时区。Hexo 默认使用您电脑的时区。时区列表。比如说:America/New_York, Japan, 和 UTC 。

其中,description主要用于SEO,告诉搜索引擎一个关于您站点的简单描述,通常建议在其中包含您网站的关键词。author参数用于主题显示文章的作者。

URL

1
2
3
4
5
6
7
url: http://tanruidd.github.io //你需要把url改成你的网站域名

root: / //网站根目录

permalink: :year/:month/:day/:title/ //文章的永久链接格式, 比如我新建一个文章叫temp.md,那么这个时候他自动生成的地址就是http://yoursite.com/2018/09/05/temp。

permalink_defaults: //永久链接中各部分的默认值
1
theme: landscape //theme就是选择什么主题,也就是在theme这个文件夹下,在官网上有很多个主题,默认给你安装的是lanscape这个主题。当你需要更换主题时,在官网上下载,把主题的文件放在theme文件夹下,再修改这个参数就可以了。

Deployment

接下来这个deploy就是网站的部署的,repo就是仓库(Repository)的简写。branch选择仓库的哪个分支。

1
2
3
4
deploy:
type: git
repo: https://github.com/tanruidd/tanruidd.github.io
branch: master

layout(布局)

1
2
3
post //路径source/_posts
page //路径source
draft //路径source/_drafts

如果你想另起一页,那么可以使用page

1
hexo new page board

系统会自动给你在source文件夹下创建一个board文件夹,以及board文件夹中的index.md,这样你访问的board对应的链接就是http://xxx.xxx/board

55885695718

draft是草稿的意思,也就是你如果想写文章,又不希望被看到,那么可以

1
hexo new draft mypage

这样会在source/_draft中新建一个newpage.md文件,如果你的草稿文件写的过程中,想要预览一下,那么可以使用

1
hexo server --draft

在本地端口中开启服务预览。

如果你的草稿文件写完了,想要发表到post中

1
hexo publish draft newpage

就会自动把newpage.md发送到post中。

更改主题

我找到了一个miho主题,看着还不错。

基本上创建主题的人都会有教程的,跟着做就好了。

设置评论系统

1
2
3
4
5
gitment: 
owner: tanruidd #你的 GitHub ID
repo: 'tanruidd.github.io' #存储评论的 repo
client_id: '' #client ID
client_secret: '' #client secret

我是通过github的gitmet设置的评论系统

需要先在setting中最后一个建立一个OAuth App

55887953332

55887957228

将生成的id和secret放入相应位置即可。

操作之后发现不行,,,不能在自己域名下使用,只能在tanruidd.github.io下评论。

所以我又找了一个方法,valine评论。

首先需要注册leancloud账户,然后创建一个应用。

55888231943

同样这里存在密钥,只不过我这个主题没有自带,所以我需要自己配置。

首先在\miho\_config.yml下增加

1
2
3
4
5
6
7
8
valine:
enable: true
appid: #your App ID
appkey: #your App Key
notify: false # mail notifier , https://github.com/xCss/Valine/wiki
verify: false # Verification code
placeholder: 来啊,快活啊!
pageSize: 10

55888246793

对应位置填写。

然后找到\miho\layout\_partial\article.ejs文件,添加如下代码到最后

1
2
3
4
5
6
7
8
9
10
11
12
13
<% if (theme.valine && theme.valine.appid && theme.valine.appkey){ %>
<section id="comments" class="comments">
<style>
.comments{margin:30px;padding:10px;background:#fff}
@media screen and (max-width:800px){.comments{margin:auto;padding:10px;background:#fff}}
</style>
<%- partial('plugins/comments/valine', {
key: post.slug,
title: post.title,
url: config.url+url_for(post.path)
}) %>
</section>
<% } %>

在\miho\layout_partial\plugins\comments新建valine.ejs文件,输入下面内容。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<div id="vcomment" class="comment"></div> 
<script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
<script src="//unpkg.com/valine/dist/Valine.min.js"></script>
<script>
var notify = '<%= theme.valine.notify %>' == true ? true : false;
var verify = '<%= theme.valine.verify %>' == true ? true : false;
window.onload = function() {
new Valine({
el: '.comment',
notify: notify,
verify: verify,
app_id: "<%= theme.valine.appid %>",
app_key: "<%= theme.valine.appkey %>",
placeholder: "<%= theme.valine.placeholder %>",
avatar:"<%= theme.valine.avatar %>"
});
}
</script>

然后生成部署一下就行了。

SEO优化

1
SEO是由英文Search Engine Optimization缩写而来, 中文意译为“搜索引擎优化”。SEO是指通过站内优化比如网站结构调整、网站内容建设、网站代码优化等以及站外优化。

推广是很麻烦的事情,怎么样别人才能知道我们呢,首先需要让搜索引擎收录你的这个网站,别人才能搜索的到。那么这就需要SEO优化了。

最后更新: 2019年05月26日 23:41

原始链接: http://tanruidd.github.io/2019/05/26/hexo配置/