安装
next主题官网网站
下载主题
1 git clone https://github.com/next-theme/hexo-theme-next themes/next
启用主题
修改博客配置文件,启用next主题
next主题配置
更换主题风格
next提供4种主题风格,可根据个人喜好选择,修改主题配置文件
开启代码块复制按钮
修改主题配置文件有default,flat,mac三种代码块复制风格供选择
1 2 3 4 5 copy_button: enable: true style: mac
开启浏览进度
修改主题配置文件
返回顶部按钮显示百分比
顶部显示进度条
1 2 reading_progress: enable: true
开启书签
会保留浏览进度修改主题配置文件
开启右上角github banner
修改主题配置文件可添加标语title
1 2 3 4 github_banner: enable: true permalink: https://github.com/yourname title: Follow me on GitHub
去掉底部Powered by Hexo & NexT
修改主题配置文件
启用菜单
修改主题配置文件
1 2 3 4 5 6 7 8 9 menu: home: / || fa fa-home tags: /tags/ || fa fa-tags categories: /categories/ || fa fa-th archives: /archives/ || fa fa-archive
添加社交按钮
修改主题配置文件
1 2 3 4 5 6 7 8 9 10 social: GitHub: https://github.com/yourname || fab fa-github Weibo: https://weibo.com/yourname || fab fa-weibo
可以添加其他社交链接,末尾图标可以从https://fontawesome.com/icons搜索添加 例如QQ和微信
1 2 QQ: tencent://message/?uin=qq号 || fab fa-qq WeChat: 微信号 || fab fa-weixin
链接也可使用图片,例如微信使用二维码图片
先将图片weixin.jpg上传至themes/next/source/images目录下
修改使用图片路径
1 WeChat: /images/weixin.jpg || fab fa-weixin
开启版权功能
修改主题配置文件
1 2 3 4 5 6 7 creative_commons: license: by-nc-sa size: small sidebar: true post: true
开启文本转流程图功能
修改主题配置文件
1 2 3 4 5 6 7 mermaid: enable: true theme: light: default dark: dark
修改博客配置文件
1 2 3 highlight: exclude_languages: - mermaid
vscode可以安装 Markdown Preview Mermaid Support 插件预览效果
next主题美化
设置头像
上传头像到themes/next/source/images目录下
修改主题配置文件文件,替换url后内容为头像路径
1 2 3 4 5 6 7 8 avatar: url: /images/head_portrait.jpg rounded: true rotated: true
启用本地搜索
安装hexo-generator-searchdb 插件
1 npm install hexo-generator-searchdb
博客配置文件,添加以下内容
1 2 3 4 5 search: path: search.xml field: post content: true format: html
修改主题配置文件
1 2 local_search: enable: true
启用文章字数统计及阅读时常功能
安装hexo-word-counter 插件
1 npm install hexo-word-counter
主题界面设置
添加背景图
创建配置目录,博客根目录下执行
上传背景图片,如background.jpg到themes/next/source/images目录下
_data目录下创建文件styles.styl,添加以下内容
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 //全局布局美化代码 body { background-image :url (/images/background.jpg ); background-repeat : no-repeat; background-attachment : fixed; background-position : center; } .post-block { background-color : rgba (255 , 255 , 255 , 1 ); // margin-top : 24px ; margin-bottom : 24px ; // padding : 20px ; border-radius : 30px 30px 30px 30px ; box-shadow : 8px 7px 2px 0 rgba (0 ,0 ,0 ,0.12 ), 7px 4px 1px -2px rgba (0 ,0 ,0 ,0.06 ), 0 1px 5px 0 rgba (0 ,0 ,0 ,0.12 ); } .main-inner { background-color : rgba (255 , 255 , 255 , 0 ); }
修改主题配置文件,去掉注释
1 style: source/_data/styles.styl
设置组件圆角
_data目录下创建文件variables.styl,添加以下内容
1 2 3 // 圆角设置 $border-radius -inner = 30px 30px 30px 30px ; $border-radius = 30px ;
修改主题配置文件,去掉注释
1 variable: source/_data/variables.styl
添加看板娘
使用[ive2d-widget]https://github.com/stevenjoezhang/live2d-widget
最简单的
_data目录下创建文件head.njk,添加以下内容
1 <script src="https://fastly.jsdelivr.net/gh/stevenjoezhang/live2d-widget@latest/autoload.js"></script>
修改主题配置文件,去掉注释
1 head: source/_data/head.njk
1 git clone https://github.com/stevenjoezhang/live2d-widget.git
添加valine评论系统
准备
注册leancloud ,创建应用
新版hexo移除了Valine,需要自行安装
1 npm install next-theme/hexo-next-valine
修改 node_modules/hexo-next-valine/default.yaml 中的配置