小序
博客搭建,可以參考博文 個人博客-GitHub-Pages
Hexo
的配置文件_config.yml分兩種:站點(diǎn)配置文件辜梳、主題配置文件我抠。站點(diǎn)配置文件參考Hexo乏沸,主題配置文件參考NexT
本文主要講解主題配置文件_config.yml(文件路徑:hexo目錄\themes\next\_config.yml)
GitHub hexo-theme-next
Site Information Settings
設(shè)置站點(diǎn)信息
favicon:修改網(wǎng)站圖標(biāo),圖片保存在目錄\themes\next\source\images中美莫。
footer:站點(diǎn)底部
since:2018站點(diǎn)創(chuàng)建時間
creative_commons:文章底部添加版權(quán)信息
Menu Settings
- 菜單項(名稱和鏈接)
- 菜單項的顯示文本
- 菜單項對應(yīng)的圖標(biāo)页眯。NexT使用的是Font Awesome提供的圖標(biāo),F(xiàn)ont Awesome提供了600+的圖標(biāo)厢呵,可以滿足絕大多數(shù)的場景窝撵。
注意:菜單點(diǎn)擊可能報Cannot GET **,創(chuàng)建page就可以了襟铭,命令如下:
// name為categories碌奉、tags短曾、about等,文件存儲路徑為:root\source
hexo new page 'name'
在source目錄下會生成菜單對應(yīng)文件夾道批,修改文件夾中的index.md文件错英,新增type屬性,如下:
---
title: 分類
date: 2018-12-16 17:03:04
type: "categories"
---
Scheme Settings
Scheme是NexT提供的一種特性隆豹,可以設(shè)置不同的外觀椭岩。同時,幾乎所有的配置都可以在Scheme之間共用璃赡。目前NexT支持以下幾種Scheme:
- Muse-默認(rèn)Scheme判哥,NexT最初的版本,黑白色調(diào)碉考,大量留白
- Mist-Muse的緊湊版本塌计,整潔有序的單欄外觀
- Pisces-雙欄Scheme,小家碧玉似的清新
- Gemini-左側(cè)網(wǎng)站信息及目錄侯谁,塊+片段結(jié)構(gòu)布局
Sidebar Settings設(shè)置側(cè)欄
- sidebar:側(cè)欄的位置
- sidebar:側(cè)欄顯示的時機(jī)
- avatar:頭像
- social:社交鏈接 github_banner:(網(wǎng)站右上角顯示關(guān)注GitHub圖標(biāo))
- Blog rolls友情鏈接
- toc:文章目錄
Post Settings
- reward:打賞
- wechat_subscriber:微信訂閱
Third Party Services Settings
local_search:網(wǎng)站添加搜索
needmoreshare2:內(nèi)容分享
- 在博客根目錄執(zhí)行如下命令:
git clone https://github.com/theme-next/theme-next-needmoreshare2 themes/next/source/lib/needsharebutton
- 主題配置文件中锌仅,搜索needmoreshare2:
評論系統(tǒng)
- 暢言 官網(wǎng)
# changyan
changyan:
enable: false
appid:
appkey:
- Valine 官網(wǎng)
DaoVoice
修改文章內(nèi)鏈接樣式
在文件\themes\next\source\css\_common\components\post\post.styl末尾,添加如下代碼:
// 文章內(nèi)鏈接文本樣式
.post-body p a{
color: #0593d3; //原始鏈接顏色
border-bottom: none;
border-bottom: 1px solid #0593d3; //底部分割線顏色
&:hover {
color: #fc6423; //鼠標(biāo)經(jīng)過顏色
border-bottom: none;
border-bottom: 1px solid #fc6423; //底部分割線顏色
}
}
修改文章底部帶#的標(biāo)簽
實現(xiàn)效果圖:
[圖片上傳失敗...(image-321b05-1566118603859)]
\themes\next\layout_macro\post.swig中找到rel="tag">#墙贱,將#替換為
<i class="fa fa-tag"></i>
文章末尾添加結(jié)束標(biāo)語
實現(xiàn)效果圖:
[圖片上傳失敗...(image-42414c-1566118603859)]
- \themes\next\layout_macro中新建passage-end-tag.swig文件热芹,添加如下代碼:
<div>
{% if not is_index %}
<div style="text-align:center;color: #ccc;font-size:14px;">-------------本文結(jié)束<i class="fa fa-paw"></i>感謝您的閱讀-------------</div>
{% endif %}
</div>
- 打開\themes\next\layout_macro\post.swig文件,在post-body后惨撇,post-footer前伊脓,添加如下代碼:
<div>
{% if not is_index %}
{% include 'passage-end-tag.swig' %}
{% endif %}
</div>
- 修改主題配置文件_config.yml,末尾添加如下內(nèi)容:
# 文章末尾添加“本文結(jié)束”標(biāo)記
passage_end_tag:
enabled: true
網(wǎng)站底部添加總訪客量魁衙、總訪問量
方法一:
打開\themes\next\layout_partials\footer.swig文件报腔,在copyright之前添加如下代碼:
<script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
單個用戶連續(xù)點(diǎn)擊n篇文章,記錄n次訪問量剖淀。
<span id="busuanzi_container_site_pv">
總訪問量<span id="busuanzi_value_site_pv"></span>次
</span>
單個用戶連續(xù)點(diǎn)擊n篇文章纯蛾,只記錄1次訪客數(shù)。
<span id="busuanzi_container_site_uv">
總訪客數(shù)<span id="busuanzi_value_site_uv"></span>人次
</span>
方法二:
主題配置文件_config.yml纵隔,搜索
busuanzi_count:
注:本地預(yù)覽時茅撞,數(shù)字存在異常,部署云端即可恢復(fù)正常巨朦。
網(wǎng)站底部添加字?jǐn)?shù)統(tǒng)計
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>
點(diǎn)擊出現(xiàn)愛心效果
- 在目錄\themes\next\source\js\src中新建文件love.js,添加如下代碼:
!function (e, t, a) { function n() { c(".heart{width: 10px;height: 10px;position: fixed;background: #f00;transform: rotate(45deg);-webkit-transform: rotate(45deg);-moz-transform: rotate(45deg);}.heart:after,.heart:before{content: '';width: inherit;height: inherit;background: inherit;border-radius: 50%;-webkit-border-radius: 50%;-moz-border-radius: 50%;position: fixed;}.heart:after{top: -5px;}.heart:before{left: -5px;}"), o(), r() } function r() { for (var e = 0; e < d.length; e++)d[e].alpha <= 0 ? (t.body.removeChild(d[e].el), d.splice(e, 1)) : (d[e].y-- , d[e].scale += .004, d[e].alpha -= .013, d[e].el.style.cssText = "left:" + d[e].x + "px;top:" + d[e].y + "px;opacity:" + d[e].alpha + ";transform:scale(" + d[e].scale + "," + d[e].scale + ") rotate(45deg);background:" + d[e].color + ";z-index:99999"); requestAnimationFrame(r) } function o() { var t = "function" == typeof e.onclick && e.onclick; e.onclick = function (e) { t && t(), i(e) } } function i(e) { var a = t.createElement("div"); a.className = "heart", d.push({ el: a, x: e.clientX - 5, y: e.clientY - 5, scale: 1, alpha: 1, color: s() }), t.body.appendChild(a) } function c(e) { var a = t.createElement("style"); a.type = "text/css"; try { a.appendChild(t.createTextNode(e)) } catch (t) { a.styleSheet.cssText = e } t.getElementsByTagName("head")[0].appendChild(a) } function s() { return "rgb(" + ~~(255 * Math.random()) + "," + ~~(255 * Math.random()) + "," + ~~(255 * Math.random()) + ")" } var d = []; e.requestAnimationFrame = function () { return e.requestAnimationFrame || e.webkitRequestAnimationFrame || e.mozRequestAnimationFrame || e.oRequestAnimationFrame || e.msRequestAnimationFrame || function (e) { setTimeout(e, 1e3 / 60) } }(), n() }(window, document);
- 打開文件\themes\next\layout_layout.swig糊啡,末尾加上如下代碼:
<!-- 頁面點(diǎn)擊小紅心 -->
<script type="text/javascript" src="/js/src/love.js"></script>
添加網(wǎng)易云音樂
\themes\next\layout_macro\sidebar.swig
[圖片上傳失敗...(image-c8d50d-1566118603859)]
[圖片上傳失敗...(image-884f68-1566118603859)]
設(shè)置背景圖片
圖片來源:https://source.unsplash.com
打開文件themes\next\source\css_custom\custom.styl拄查,添加如下代碼:
body {
background:url(https://source.unsplash.com/1600x900/daily?nature,water);
background-repeat: no-repeat;
background-attachment:fixed;
background-position:50% 50%;
}
添加依賴
在目錄\themes\next下,開啟Git Bash棚蓄,執(zhí)行命令堕扶。
設(shè)置動態(tài)背景
canvas_nest:
git clone https://github.com/theme-next/theme-next-canvas-nest source/lib/canvas-nest
站點(diǎn)頂部進(jìn)度條
pace:
git clone https://github.com/theme-next/theme-next-pace source/lib/pace