hexo + NextT主题配置快速教程

前言

博客的初衷是为了写文章、发布文章,追求简洁和加载速度。最终选择了NextT主题。

NextT主题Github地址

NextT主题官方文档

更换主题

下载NextT主题

t1

下载后解压ZIP,把文件夹名字修改成NextT,并把主题文件夹复制到 D:\Myblog\themes里面。

修改主题

用vs code(你也可以用其他编辑器)打开 D:\Myblog\_config.yml,搜索theme,修改为:NextT,保存并退出。

t2

博客面貌仔细修改

改主题样式

D:\Myblog\themes\NextT\_config.yml,搜索 Scheme——> 改用 scheme: Gemini

t3

语言设置

NextT很容易出现德语的情况,所以打开 D:\Myblog\_config.yml,把语言改成:

1
language: en

t16

添加目录栏选项

D:\Myblog\themes\NextT\_config.yml,搜索 menu——> 设置 about、archives、categories、tags、Books、Video、Game。

添加新的栏:

1
2
3
4
5
6
7
8
9
menu:
about: /about/ || user
archives: /archives/ || archive
categories: /categories/ || th
tags: /tags/ || tags
Books: /Books/ || eye
Video: /Video/ || play-circle
Game: /Game/ || gamepad
#home: / || home

之后在D:\Myblog右键Git Bash here:

1
2
3
$ hexo new page "archives"

#以及其他菜单项categories、tags、Books、Video、Game。

打开 D:\Myblog\source,打开对应md文件,一一修改type:

1
2
3
title: categories
date: 2019-05-15 17:29:26
type: "categories"

t4

t44

代码块主题

D:\Myblog\themes\NextT\_config.yml,搜索 highlight_theme——> 改为 night eighties

t5

侧边栏

D:\Myblog\themes\NextT\_config.yml,搜索 social——>开启微博

t6

首页文章摘要

D:\Myblog\themes\NextT\_config.yml,搜索 auto_excerpt——>开启

t7

标签图标更改

打开D:\Myblog\themes\NextT\layout\_marcro\post.swig文件,搜索 post_tags,将 #号 换成<i class="fa fa-tag"></i>

t8

添加背景动态js

https://github.com/theme-next/theme-next-canvas-nest

D:\Myblog\themes\NextT文件夹下,Git Bash here:

1
$ git clone https://github.com/theme-next/theme-next-canvas-nest source/lib/canvas-nest

打开D:\Myblog\themes\NextT\_config.yml,修改:

1
2
3
4
5
6
7
canvas_nest:
enable: true
onmobile: true # display on mobile or not
color: "255,0,0" # RGB values, use ',' to separate, 改成红色了
opacity: 0.7 # the opacity of line: 0~1
zIndex: -1 # z-index property of the background
count: 150 # the number of lines

t9

加载条

https://github.hubspot.com/pace/docs/welcome/

PS:如果网页加载慢,就关掉这个

D:\Myblog\themes\NextT文件夹下,Git Bash here:

1
$ git clone https://github.com/theme-next/theme-next-pace source/lib/pace

D:\Myblog\themes\NextT\_config.yml

1
2
pace: true
pace_theme: pace-theme-big-counter

t10

关注Github

http://tholman.com/github-corners/

打开D:\Myblog\themes\NextT\layout\_layout.swig文件,搜索<div class="headband"></div> 将复制的内容粘贴到<div class="headband"></div>下面,如下:

1
<a href="https://github.com/sailorlisa" class="github-corner" aria-label="View source on GitHub"><svg width="92" height="92" viewBox="0 0 250 250" style="fill:#b495e3; color:#fff; position: absolute; top: 0; border: 0; right: 0;" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a><style>.github-corner:hover .octo-arm{animation:octocat-wave 560ms ease-in-out}@keyframes octocat-wave{0%,100%{transform:rotate(0)}20%,60%{transform:rotate(-25deg)}40%,80%{transform:rotate(10deg)}}@media (max-width:500px){.github-corner:hover .octo-arm{animation:none}.github-corner .octo-arm{animation:octocat-wave 560ms ease-in-out}}</style>

也可以修改D:\Myblog\themes\NextT\_config.yml里:

1
2
3
4
github_banner:
enable: true
permalink: https://github.com/sailorlisa
title: Follow me on GitHub

t11

白猫插件

Github地址:https://github.com/EYHN/hexo-helper-live2d/blob/master/README.zh-CN.md

1
2
3
$ npm install --save hexo-helper-live2d

$ npm install live2d-widget-model-tororo

之后在D:\Myblog\_config.yml最后添加内容:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# 白猫模型
live2d:
enable: true
scriptFrom: local
pluginRootPath: live2dw/
pluginJsPath: lib/
pluginModelPath: assets/
tagMode: false
debug: false
model:
use: live2d-widget-model-tororo
display:
position: right
width: 150
height: 300
mobile:
show: false #手机上不显示

t12

图片文件夹插件

1.将 D:\Myblog\_config.yml文件中的 post_asset_folder 选项设为 true

2.D:\Myblog,右键Git Bash here,输入:

1
$ npm install hexo-asset-image --save

t13

添加搜索栏

D:\Myblog,右键Git Bash here,输入:

1
$  npm install hexo-generator-searchdb --save

D:\Myblog\_config.yml添加:

1
2
3
4
5
6
#表示站内搜索
search:
path: search.xml
field: post
format: html
limit: 10000

D:\Myblog\themes\NextT\_config.yml,搜索local_search

1
2
local_search:
enable: true

t14

标签云

https://github.com/MikeCoder/hexo-tag-cloud

D:\Myblog,右键Git Bash here,输入:

1
$ npm install hexo-tag-cloud --save

D:\Myblog\themes\NextT\layout\_macro\sidebar.swig,然后添加内容:

1
2
3
4
5
6
7
8
9
10
11
12
{% if site.tags.length > 1 %}
<script type="text/javascript" charset="utf-8" src="{{ url_for('/js/tagcloud.js') }}"></script>
<script type="text/javascript" charset="utf-8" src="{{ url_for('/js/tagcanvas.js') }}"></script>
<div class="widget-wrap">
<h3 class="widget-title">Tag Cloud</h3>
<div id="myCanvasContainer" class="widget tagcloud">
<canvas width="250" height="250" id="resCanvas" style="width=100%">
{{ list_tags() }}
</canvas>
</div>
</div>
{% endif %}

D:\Myblog\_config.yml添加:

1
2
3
4
5
6
7
# hexo-tag-cloud
tag_cloud:
textFont: Trebuchet MS, Helvetica
textColor: '#333'
textHeight: 22
outlineColor: '#E2E1D1'
maxSpeed: 0.2

t15

最后预览部署

1
2
3
4
$ hexo clean && hexo g && hexo s
#预览之后没问题就部署

$ hexo d