【hexo主题自定义】
主题下载安装
进入命令行,下载 NexT 主题,输入:
git clone https://github.com/theme-next/hexo-theme-next themes/next
修改站点配置文件_config.yml,找到如下代码:
## Themes: https://hexo.io/themes/
theme: landscape
将 landscape 修改为 next 即可。
配置文件
在 Hexo 中有两份主要的配置文件,其名称都是 _config.yml。 其中,一份位于站点根目录下,主要包含 Hexo 本身的站点配置;另一份位于主题目录下,这份配置由主题作者提供,主要用于配置主题相关的选项。
为了描述方便,在以下说明中,将前者称为 站点配置文件, 后者称为 主题配置文件。
/hexo/_config.yml
/hexo/themes/next/_config.yml
修改语言
打开站点配置文件,搜索 language,找到如下代码:
author:
language:
timezone:
在 language 后面输入 zh-CN
。
新建标签及分类界面
打开 主题配置文件,搜索 menu,找到如下代码:
menu:home: / || home#about: /about/ || user#tags: /tags/ || tags#categories: /categories/ || tharchives: /archives/ || archive#schedule: /schedule/ || calendar#sitemap: /sitemap.xml || sitemap#commonweal: /404/ || heartbeat
把 tags 和 categories 前面的 # 删除,
切换主题
next 主题自带四种样式。
在主题配置文件/next/_config.yml中查找:scheme,找到如下代码:
# Schemes
scheme: Muse
#scheme: Mist
#scheme: Pisces
#scheme: Gemini
选择你喜欢的一种样式,去掉前面的 #,其他主题前加上 # 即可。
文章添加阴影
打开 /themes/next/source/css/_custom/custom.styl,添加:
.post {
margin-top: 60px;
margin-bottom: 60px;
padding: 25px;
-webkit-box-shadow: 0 0 5px rgba(202, 203, 203, .5);
-moz-box-shadow: 0 0 5px rgba(202, 203, 204, .5);
}
Local Search本地搜索
安装插件hexo-generator-searchdb,执行以下命令:
npm install hexo-generator-searchdb --save
修改hexo/_config.yml站点配置文件,新增以下内容到任意位置:
search:
path: search.xml
field: post
format: html
limit: 10000
编辑 主题配置文件,启用本地搜索功能:
# Local search
local_search:
enable: true
头像设置圆形,停留旋转效果
修改themes\next\source\css_common\components\sidebar\sidebar-author.styl,新增以下代码:
.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: 50%;
+ transition: 2s all;
}//旋转
+ .site-author-image:hover{
+ transform: rotate(360deg);
+ }