Hexo博客Next6.0版本主题配置(站内搜索、新建404界面、静态资源压缩、底部信息隐藏、各版块透明度修改、字数统计、推荐阅读、博文置顶、阅读进度、在线评论、运行时间)
新建404界面
在站点根目录下,输入hexo new page 404
,在默认Hexo站点下/source/404/index.md
打开新建的404界面,编辑属于自己的404界面,可以显示腾讯公益404界面,代码如下:
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8;"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="robots" content="all" />
<meta name="robots" content="index,follow"/>
<link rel="stylesheet" type="text/css" href="https://qzone.qq.com/gy/404/style/404style.css">
</head>
<body>
<script type="text/plain" src="http://www.qq.com/404/search_children.js"
charset="utf-8" homePageUrl="/"
homePageName="回到我的主页">
</script>
<script src="https://qzone.qq.com/gy/404/data.js" charset="utf-8"></script>
<script src="https://qzone.qq.com/gy/404/page.js" charset="utf-8"></script>
</body>
</html>
静态资源压缩
静态资源压缩
在站点目录下安装插件:
$ npm install gulp -g
npm install gulp-minify-css --save
npm install gulp-uglify --save
npm install gulp-htmlmin --save
npm install gulp-htmlclean --save
npm install gulp-imagemin --save
在Hexo站点下添加gulpfile.js
文件,文件内容如下:
var gulp = require('gulp');
var minifycss = require('gulp-minify-css');
var uglify = require('gulp-uglify');
var htmlmin = require('gulp-htmlmin');
var htmlclean = require('gulp-htmlclean');
var imagemin = require('gulp-imagemin');
// 压缩css文件
gulp.task('minify-css', function() {
return gulp.src('./public/**/*.css')
.pipe(minifycss())
.pipe(gulp.dest('./public'));
});
// 压缩html文件
gulp.task('minify-html', function() {
return gulp.src('./public/**/*.html')
.pipe(htmlclean())
.pipe(htmlmin({
removeComments: true,
minifyJS: true,
minifyCSS: true,
minifyURLs: true,
}))
.pipe(gulp.dest('./public'))
});
// 压缩js文件
gulp.task('minify-js', function() {
return gulp.src(['./public/**/.js','!./public/js/**/*min.js'])
.pipe(uglify())
.pipe(gulp.dest('./public'));
});
// 压缩 public/demo 目录内图片
gulp.task('minify-images', function() {
gulp.src('./public/demo/**/*.*')
.pipe(imagemin({
optimizationLevel: 5, //类型:Number 默认:3 取值范围:0-7(优化等级)
progressive: true, //类型:Boolean 默认:false 无损压缩jpg图片
interlaced: false, //类型:Boolean 默认:false 隔行扫描gif进行渲染
multipass: false, //类型:Boolean 默认:false 多次优化svg直到完全优化
}))
.pipe(gulp.dest('./public/uploads'));
});
// 默认任务
gulp.task('default', [
'minify-html','minify-css','minify-js','minify-images'
]);
需要只在每次执行generate命令后执行gulp就可以实现对静态资源的压缩,完成压缩后执行deploy命令同步到服务器:
hexo g
gulp
hexo d
隐藏网页底部powered By Hexo / 强力驱动
打开themes/next/layout/_partials/footer.swig
,使用<!--
与-->
隐藏之间的代码即可,或者直接删除。位置如图:
各版块透明度修改
内容板块透明
根博客目录themes\next\source\css\_schemes\Pisces\_layout.styl
文件.content-wrap
标签下background: white
修改为:
background: rgba(255,255,255,0.7); //0.7是透明度
菜单栏背景
根博客目录themes\next\source\css\_schemes\Pisces\_layout.styl
文件.header-inner
标签下background: white
修改为:
background: rgba(255,255,255,0.7); //0.7是透明度
站点概况背景
根博客目录themes\next\source\css\_schemes\Pisces\_sidebar.styl
文件.sidebar-inner
标签下background: white
修改为:
background: rgba(255,255,255,0.7); //0.7是透明度
修改然后根博客目录themes\next\source\css\_schemes\Pisces\_layout.styl
文件.sidebar
标签下background: $body-bg-color
修改为:
background: rgba(255,255,255,0.7); //0.7是透明度
网站底部字数统计
具体方法实现
切换到根目录下,然后运行如下代码
npm install hexo-wordcount --save
然后在/themes/next/layout/_partials/footer.swig
文件尾部加上:
<div class="theme-info">
<div class="powered-by"></div>
<span class="post-count">博客全站共{{ totalcount(site) }}字</span>
</div>
添加侧栏推荐阅读
编辑主题配置文件,如下配置即可:
# Blog rolls
links_icon: link
links_title: 推荐阅读
#links_layout: block
links_layout: inline
links:
Swift 4: https://developer.apple.com/swift/
Objective-C: https://developer.apple.com/documentation/objectivec
博文置顶
修改hexo-generator-index
插件,把node_modules/hexo-generator-index/lib/generator.js
中代码替换为:
'use strict';
var pagination = require('hexo-pagination');
module.exports = function(locals){
var config = this.config;
var posts = locals.posts;
posts.data = posts.data.sort(function(a, b) {
if(a.top && b.top) { // 两篇文章top都有定义
if(a.top == b.top) return b.date - a.date; // 若top值一样则按照文章日期降序排
else return b.top - a.top; // 否则按照top值降序排
}
else if(a.top && !b.top) { // 以下是只有一篇文章top有定义,那么将有top的排在前面(这里用异或操作居然不行233)
return -1;
}
else if(!a.top && b.top) {
return 1;
}
else return b.date - a.date; // 都没定义按照文章日期降序排
});
var paginationDir = config.pagination_dir || 'page';
return pagination('', posts, {
perPage: config.index_generator.per_page,
layout: ['index', 'archive'],
format: paginationDir + '/%d/',
data: {
__index: true
}
});
};
文章添加Top值,值越大,越靠前:
---
title: Hexo-NexT主题配置
date: 2018-01-20 20:41:08
categories: Hexo
tags:
- Hexo
- NexT
top: 100
---
网页底部信息隐藏
网页底默认最新一次使用,需要取消since
注释,设定年份
footer:
# Specify the date when the site was setup.
# If not defined, current year will be used.
since: 2017
# Icon between year and copyright info.
icon:
# Icon name in fontawesome, see: https://fontawesome.com/v4.7.0/icons/
# `heart` is recommended with animation in red (#ff0000).
name: user #设置图标,想修改图标从https://fontawesome.com/v4.7.0/icons获取
# If you want to animate the icon, set it to true.
animated: false
# Change the color of icon, using Hex Code.
color: "#808080"
# If not defined, `author` from Hexo main config will be used.
copyright: by AomanHao #版权
显示文章阅读进度百分比
设置方法:
打开themes/next/_config.yml
主题配置文件,找到# Scroll percent label in b2t button
将scrollpercent:
的值,改成true
# Scroll percent label in b2t button
scrollpercent: true
浏览页面的时候显示当前浏览进度
如果想把top按钮放在侧边栏,打开themes/next
下的_config.yml
,搜索关键字b2t
,把false
改为true
# Back to top in sidebar
b2t: true
# Scroll percent label in b2t button
scrollpercent: true
加入valine在线评论
设置效果:
设置方法:
首先要先去LeanCloud注册一个帐号.然后再创建一个应用.
拿到appid
和appkey
之后,打开themes/next/_config.yml
主题配置文件,查找valine
,填入appid
和 appkey
我的配置:
添加网站已运行时间
在themes/layout/_parrials/footer.swing
后添加
<span id="timeDate">载入天数...</span><span id="times">载入时分秒...</span>
<script>
var now = new Date();
function createtime() {
var grt= new Date("11/27/2017 12:00:00");//在此处修改你的建站时间
now.setTime(now.getTime()+250);
days = (now - grt ) / 1000 / 60 / 60 / 24; dnum = Math.floor(days);
hours = (now - grt ) / 1000 / 60 / 60 - (24 * dnum); hnum = Math.floor(hours);
if(String(hnum).length ==1 ){hnum = "0" + hnum;} minutes = (now - grt ) / 1000 /60 - (24 * 60 * dnum) - (60 * hnum);
mnum = Math.floor(minutes); if(String(mnum).length ==1 ){mnum = "0" + mnum;}
seconds = (now - grt ) / 1000 - (24 * 60 * 60 * dnum) - (60 * 60 * hnum) - (60 * mnum);
snum = Math.round(seconds); if(String(snum).length ==1 ){snum = "0" + snum;}
document.getElementById("timeDate").innerHTML = " Runing "+dnum+" D ";
document.getElementById("times").innerHTML = hnum + " H " + mnum + " M " + snum + " S";
}
setInterval("createtime()",250);
</script>
添加头像
打开themes/next下的_config.yml
文件,搜索 Avatar
关键字,修改url的参数
avatar:
# in theme directory(source/images): /images/avatar.gif
# in site directory(source/uploads): /uploads/avatar.gif
# You can also use other linking images.
url: /images/avatar.gif
# If true, the avatar would be dispalyed in circle.
rounded: true
# The value of opacity should be choose from 0 to 1 to set the opacity of the avatar.
opacity: 1
# If true, the avatar would be rotated with the cursor.
rotated: false
url链接默认是themes/next/source/images
下的avatar.gif
文件,有两种方法修改连接
1、本地连接,不建议用比较大的图片(大于1M文件),加载图片需要时间
url: /images/avatar.gif
或者
url: /images/xx.jpg等类型图片
2、图床外链,建议使用
url: http://example.com/avatar.png
添加站内搜索
设置效果:
设置方法:
安装hexo-generator-searchdb
插件
npm install hexo-generator-searchdb --save
编辑_config.yml
站点配置文件,新增以下内容到任意位置:
search:
path: search.xml
field: post
format: html
limit: 10000
编辑themes/next/_config.yml
主题配置文件,启用本地搜索功能,将local_search:
下面的enable:
的值,改成true
# Local search
local_search:
enable: true
底部跳动图标实现
注意点:需要到next\layout_partials下的footer.swig
文件中,在你所需要调动的图标所对应的span中增加对应的ID
去到主体的css
文件(next\source\css_variables\custom.styl
,增加以下代码即可
//底部爱心小图标跳动
keyframes heartAnimate {
0%,100%{transform:scale(1);}
10%,30%{transform:scale(0.9);}
20%,40%,60%,80%{transform:scale(1.1);}
50%,70%{transform:scale(1.1);}
}
//图标所对应的span中的ID
#heart {
animation: heartAnimate 1.33s ease-in-out infinite;
}
.with-love {
color: rgb(255, 113, 113);
}
我的个人博客文章地址,欢迎访问
我的CSDN文章地址,欢迎访问
我的简书文章地址,欢迎访问
我的GitHub主页,欢迎访问
Hexo博客Next6.0版本主题配置(站内搜索、新建404界面、静态资源压缩、底部信息隐藏、各版块透明度修改、字数统计、推荐阅读、博文置顶、阅读进度、在线评论、运行时间)的更多相关文章
- Hexo博客Next v7.X 主题升级,美化警示录
本文转载于:Hexo博客Next v7.X 主题升级,美化警示录丨奥怪的小栈 前言 经历了好几天(懒癌晚期懒得数了)的与主题升级斗争后,我终于完成基本上完成了next主题的升级!升到了V7.3!哈哈哈 ...
- Hexo博客搭建以及Next主题美化的经验之谈
这并不是一篇博客搭建教程.内容主要包含个人对于Hexo博客搭建的心得,Next6.0主题美化的部分建议,以及摘录一些各种用于博客搭建的link. 在博客园3年6个月,确实也学到了很多,博客园也是目前为 ...
- Hexo next主题添加站内搜索功能
根据关键字搜索博文,站内搜索的功能很实用.hexo开启站内搜索很方便,已经有现成的插件可以使用,也是为了方便自己 安装插件 npm install hexo-generator-search --sa ...
- Hexo 博客 github.io MD
Markdown版本笔记 我的GitHub首页 我的博客 我的微信 我的邮箱 MyAndroidBlogs baiqiantao baiqiantao bqt20094 baiqiantao@sina ...
- Hexo 博客利用 Nginx 实现中英文切换
本文记录了对 Hexo 博客进行中英文切换的配置过程,实现同一应用共用模版,任何页面可以切换到另一语言的对应页面,并对未明确语言的访问地址,根据浏览器语言进行自动跳转 实现细则 中英文地址区分 博客中 ...
- Hexo博客框架攻略
前言 前天无意在b站看到up主CodeSheep上传的博客搭建教程,引起了我这个有需求但苦于没学过什么博客框架的小白的兴趣.于是花了两天时间终于终于把自己的博客搭建好了,踩了无数的坑,走偏了无数的路, ...
- hexo搭建博客系列(三)美化主题
文章目录 其他搭建 1. 添加博客图标 2. 鼠标点击特效(二选一) 2.1 红心特效 2.2 爆炸烟花 3. 设置头像 4. 侧边栏社交小图标设置 5. 文章末尾的标签图标修改 6. 访问量统计 7 ...
- U盘便携式hexo&博客搭建&极速纯净低bug主题推荐&部署到coding&SEO优化搜索
指南:U盘便携式hexo&博客搭建&极速纯净低bug主题推荐&部署到coding&SEO优化搜索 U盘便携式hexo随处写博客 简述:在任意一台联网的电脑上续写he ...
- hexo博客yili主题个性化自定义教程(1) ——借鉴中学习,初认yili主题
文章转载于:hexo博客yili主题个性化自定义教程(1) --借鉴中学习,初认yili主题 这个博客跌跌撞撞也弄了好多天了,由于Next主题不知道什么情况,被我玩坏了.所以换了一个主题. 大名鼎鼎的 ...
- hexo博客的优化与配置——加入统计代码
今天看着csdn博客的訪客数,就想给hexo博客也加入统计訪客的插件,上次折腾了个pacman主题,中间自带的是goole的统计,easy被墙,所以就想换一个统计工具,看了好多人用的都是cnzz的站长 ...
随机推荐
- 今天能恢复我的Django吗——恢复了!
今天能用两小时恢复我的Django吗 实在是累了,昨天和队友改bug的时候为了能在我的电脑上实现他的程序就在datagrip中删了我django建的表.没想到啊,这一删就全是报错!! 不说了,今天看看 ...
- Linux系统如何查看内核版本信息
使用如下命令: cat /etc/os-release 显示结果如下,系统内核不同,信息不同.
- PTA 4-6次总结
(1)前言: 04:这次题目集主要学习了:使用LinkedHashSet删除arraylist中的重复数据,封装,了解Scanner类中nextLine()等方法.String类中split()等方法 ...
- 2022-10-22:以下go语言代码输出什么?A:moonfdd1;B:编译错误;C:运行时 panic。 package main import “fmt“ func main() {
2022-10-22:以下go语言代码输出什么?A:moonfdd1:B:编译错误:C:运行时 panic. package main import "fmt" func main ...
- 2020-12-06:mysql中,多个索引会有多份数据吗?
福哥答案2020-12-06: 数据不会有多份,索引有几个就有几份.聚簇索引存数据和索引,非聚簇索引存索引,聚簇索引只有一个,非聚簇索引可以有多个.
- 2022-02-16:将数组分割成和相等的子数组。 给定一个有 n 个整数的数组,你需要找到满足以下条件的三元组 (i, j, k) : 0 < i, i + 1 < j, j + 1 < k < n
2022-02-16:将数组分割成和相等的子数组. 给定一个有 n 个整数的数组,你需要找到满足以下条件的三元组 (i, j, k) : 0 < i, i + 1 < j, j + 1 & ...
- Random库用法详解
梅森旋转算法实现 基本随机数函数 seed(a=None): 初始化给定的随机数种子,默认为当前系统时间. 只要随机数种子相同,产生的随机数序列也相同. random(): 生成一个[0.0,1.0] ...
- 对promise的简单理解
随着ES6的推行它的许多新特性受到了广大开发者的好评,比如promise,为什么使用这个promise呢,他具体能帮我们做些啥? 其实从字面意思上来理解promise就是承诺,比如:你命令你的手下本月 ...
- Elasticsearch 之 join 关联查询及使用场景
在Elasticsearch这样的分布式系统中执行类似SQL的join连接是代价是比较大的,然而,Elasticsearch却给我们提供了基于水平扩展的两种连接形式 .这句话摘自Elasticsear ...
- MySQL中字符串查询效率大比拼
背景 最近有个同事对字符串加索引,加完后,发现多了个奇奇怪怪的数字执行的SQL如下: alter table string_index_test add index `idx_name` (`name ...