自定义hexo的Next主题 s1

概览:

主题

Scheme 是 NexT 提供的一种特性,借助于 Scheme,NexT 为你提供多种不同的外观。同时,几乎所有的配置都可以 在 Scheme 之间共用。目前 NexT 支持三种 Scheme,他们是:

  • Muse - 默认 Scheme,这是 NexT 最初的版本,黑白主调,大量留白
  • Mist - Muse 的紧凑版本,整洁有序的单栏外观
  • Pisces - 双栏 Scheme,小家碧玉似的清新

Scheme 的切换通过更改 主题配置文件,搜索 scheme 关键字。 你会看到有三行 scheme 的配置,将你需用启用的 scheme 前面注释 # 去除即可。
选择 Pisces Scheme

1
2
3
#scheme: Muse
#scheme: Mist
scheme: Pisces

语言

编辑 站点配置文件, 将 language 设置成你所需要的语言。建议明确设置你所需要的语言,例如选用简体中文,配置如下:

1
language: zh-CN

目前 NexT 支持的语言如以下表格所示:

语言代码设定示例
Englishenlanguage: en
简体中文zh-CNlanguage: zh-CN
Françaisfr-FRlanguage: fr-FR
Portuguêsptlanguage: pt or language: pt-BR
Русский языкrulanguage: ru
Deutschdelanguage: de
日本語jalanguage: ja
Indonesianidlanguage: id
Koreankolanguage: ko

菜单

菜单配置包括三个部分,第一是菜单项(名称和链接),第二是菜单项的显示文本,第三是菜单项对应的图标。 NexT 使用的是 Font Awesome 提供的图标, Font Awesome 提供了 600+ 的图标,可以满足绝大的多数的场景,同时无须担心在 Retina 屏幕下 图标模糊的问题。
编辑 主题配置文件,修改以下内容:
1.设定菜单内容,对应的字段是 menu。 菜单内容的设置格式是:item name: link。其中 item name 是一个名称,这个名称并不直接显示在页面上,她将用于匹配图标以及翻译。
菜单示例配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# ---------------------------------------------------------------
# Menu Settings
# ---------------------------------------------------------------

# When running the site in a subdirectory (e.g. domain.tld/blog), remove the leading slash from link value (/archives -> archives).
# Usage: `Key: /link/ || icon`
# Key is the name of menu item. If the translation for this item is available, the translated text will be loaded, otherwise the Key name will be used. Key is case-senstive.
# Value before `||` delimiter is the target link.
# Value after `||` delimiter is the name of FontAwesome icon. If icon (with or without delimiter) is not specified, question icon will be loaded.
# External url should start with http:// or https://
menu:
home: / || home
#categories: /categories/ || th
archives: /archives/ || archive
#schedule: /schedule/ || calendar
tags: /tags/ || tags
about: /about/ || user
sitemap: /sitemap.xml || sitemap
Follow me on GitHub: https://github.com/ka1i || github
#commonweal: /404/ || heartbeat

NexT 默认的菜单项有(标注 的项表示需要手动创建这个页面):

键值设定值显示文本(简体中文)
homehome: /主页
archivesarchives: /archives归档页
categoriescategories: /categories分类页
tagstags: /tags标签页
aboutabout: /about关于页面
commonwealcommonweal: /404.html公益 404
运行命令创建
1
2
3
hexo new page 'tags' #创建tags子目录
hexo new page 'about' #创建about子目录
hexo new page 'categories' #创建categories子目录
在你的网站根目录下面的source文件夹会分别生成tags、categories以及about文件夹。

分别修改这tags和categories文件夹中的index.md文件,新增type属性,如下:

1
2
3
4
5
---
title: tags
date: 2018-01-04 11:45:41
type: tags
---

categories的修改类似。

当你新建一篇博文的时候,增加上tags和categories属性值,就能在tags和categories界面检索到你的文章了。

头像

编辑 主题配置文件, 修改字段 avatar, 值设置成头像的链接地址。其中,头像的链接地址可以是:

地址
完整的互联网 URIhttp://example.com/avatar.png
站点内的地址

放置在source/images/目录下
配置为:avatar: /images/avatar.png

作者昵称

编辑 站点配置文件, 设置 author 为你的昵称。
打开\themes\next\source\css\_common\components\sidebar\sidebar-author.styl,在里面添加如下代码:

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
.site-author-image {
display: block;
margin: 0 auto;
padding: $site-author-image-padding;
max-width: $site-author-image-width;
height: $site-author-image-height;
border: $site-author-image-border-width solid $site-author-image-border-color;

/* 头像圆形 */
border-radius: 80px;
-webkit-border-radius: 80px;
-moz-border-radius: 80px;
box-shadow: inset 0 -1px 0 #333sf;

/* 设置循环动画 [animation: (play)动画名称 (2s)动画播放时长单位秒或微秒 (ase-out)动画播放的速度曲线为以低速结束
(1s)等待1秒然后开始动画 (1)动画播放次数(infinite为循环播放) ]*/


/* 鼠标经过头像旋转360度 */
-webkit-transition: -webkit-transform 1.0s ease-out;
-moz-transition: -moz-transform 1.0s ease-out;
transition: transform 1.0s ease-out;
}

img:hover {
/* 鼠标经过停止头像旋转
-webkit-animation-play-state:paused;
animation-play-state:paused;*/

/* 鼠标经过头像旋转360度 */
-webkit-transform: rotateZ(360deg);
-moz-transform: rotateZ(360deg);
transform: rotateZ(360deg);
}

/* Z 轴旋转动画 */
@-webkit-keyframes play {
0% {
-webkit-transform: rotateZ(0deg);
}
100% {
-webkit-transform: rotateZ(-360deg);
}
}
@-moz-keyframes play {
0% {
-moz-transform: rotateZ(0deg);
}
100% {
-moz-transform: rotateZ(-360deg);
}
}
@keyframes play {
0% {
transform: rotateZ(0deg);
}
100% {
transform: rotateZ(-360deg);
}
}

站点描述

编辑 站点配置文件, 设置 description 字段为你的站点描述。站点描述可以是你喜欢的一句签名:)

主页显示文章摘要

编辑 站点配置文件,设置per_page字段

1
per_page: 10

那么每页显示10篇文章,这样的话主页就看起来不是很精简了,可以通过下面的方法来配置主页只显示文章摘要:
主题配置文件中配置:把enable项配置为true就可以了。

1
2
3
4
5
# Automatically Excerpt. Not recommand.
# Please use <!-- more --> in the post to control excerpt accurately.
auto_excerpt:
enable: true
length: 150

但是我们也可以看到注释中是不推荐这样做的,因为这样会强制把文章前150个字符做为摘要的,会出现描述不完整的情况,而且有时候会把文章的源码显示出来。
那么我们就用推荐的在文章中用<!-- more –>这种方式来作为文章摘要的方式,可以根据每篇文章的不同情况自己来把控摘要的内容。