前言

笔者在用 Jekyll 搭建个人博客时踩了很多的坑,最后发现了一款不错的主题 jekyll-theme-next,但网上关于 Jekyll 版的 Next 主题优化教程少之又少,于是就决定自己写一篇以供参考。

My Blog ? 传送门
本文仅讲述 Next (Jekyll) 主题的深度优化操作,关于主题的基础配置请移步官方文档

主题优化

修改内容区域的宽度

打开 _sass/_custom/custom.scss 文件,新增变量:

  1. // 修改成你期望的宽度
  2. $content-desktop = 700px
  3. // 当视窗超过 1600px 后的宽度
  4. $content-desktop-large = 900px

此方法不适用于 Pisces Scheme

当你使用Pisces风格时可以用下面的方法:

  • 编辑 Pisces Scheme 的 _sass/_schemes/Pisces/_layout.scss 文件,在最底部添加如下代码:

    1. header{ width: 90%; }
    2. .container .main-inner { width: 90%; }
    3. .content-wrap { width: calc(100% - 260px); }

    对于有些浏览器或是移动设备,效果可能不是太好

  • 编辑 Pisces Scheme 的 _sass/_schemes/Pisces/_layout.scss 文件,修改以下内容:

    1. // 将 .header 中的
    2. width: $main-desktop;
    3. // 改为:
    4. width: 80%;
    5. // 将 .container .main-inner 中的:
    6. width: $main-desktop;
    7. // 改为:
    8. width: 80%;
    9. // 将 .content-wrap 中的:
    10. width: $content-desktop;
    11. // 改为:
    12. width: calc(100% - 260px);

    还是不知道如何修改的话,可以直接赋值笔者改好的 ? 传送门

背景透明度

打开 _sass/_custom/custom.scss 文件,新增变量:

  1. //文章内容背景改成了半透明
  2. .content-wrap {
  3. background: rgba(255, 255, 255, 0.8);
  4. }
  5. .sidebar {
  6. background: rgba(255, 255, 255, 0.1);
  7. box-shadow: 0 2px 6px #dbdbdb;
  8. }
  9. .site-nav{
  10. box-shadow: 0px 0px 0px 0px rgba(0, 0, 0, 0.8);
  11. }
  12. .sidebar-inner {
  13. background: rgba(255, 255, 255, 0.8);
  14. box-shadow: 0 2px 6px #dbdbdb;
  15. }
  16. .header-inner {
  17. background: rgba(255, 255, 255, 0.8);
  18. box-shadow: 0 2px 6px #dbdbdb;
  19. }
  20. .footer {
  21. font-size: 14px;
  22. color: #434343;
  23. }

自定义背景图片

打开 _sass/_custom/custom.scss 文件,新增变量:

  1. body{
  2. background:url(https://images8.alphacoders.com/929/929202.jpg);
  3. background-size:cover;
  4. background-repeat:no-repeat;
  5. background-attachment:fixed;
  6. background-position:center;
  7. }

url() 中可以时本地图片,也可以是图片链接

彩色时间轴

打开 _sass/_custom/custom.scss 文件,新增变量:

  1. // 时间轴样式
  2. .posts-collapse {
  3. margin: 50px 0px;
  4. }
  5. @media (max-width: 1023px) {
  6. .posts-collapse {
  7. margin: 50px 20px;
  8. }
  9. }
  10. // 时间轴左边线条
  11. .posts-collapse::after {
  12. margin-left: -2px;
  13. background-image: linear-gradient(180deg,#f79533 0,#f37055 15%,#ef4e7b 30%,#a166ab 44%,#5073b8 58%,#1098ad 72%,#07b39b 86%,#6dba82 100%);
  14. }
  15. // 时间轴左边线条圆点颜色
  16. .posts-collapse .collection-title::before {
  17. background-color: rgb(255, 255, 255);
  18. }
  19. // 时间轴文章标题左边圆点颜色
  20. .posts-collapse .post-header:hover::before {
  21. background-color: rgb(161, 102, 171);
  22. }
  23. // 时间轴年份
  24. .posts-collapse .collection-title h1, .posts-collapse .collection-title h2 {
  25. color: rgb(102, 102, 102);
  26. }
  27. // 时间轴文章标题
  28. .posts-collapse .post-title a {
  29. color: rgb(80, 115, 184);
  30. }
  31. .posts-collapse .post-title a:hover {
  32. color: rgb(161, 102, 171);
  33. }
  34. // 时间轴文章标题底部虚线
  35. .posts-collapse .post-header:hover {
  36. border-bottom-color: rgb(161, 102, 171);
  37. }
  38. // archives页面顶部文字
  39. .page-archive .archive-page-counter {
  40. color: rgb(0, 0, 0);
  41. }
  42. // archives页面时间轴左边线条第一个圆点颜色
  43. .page-archive .posts-collapse .archive-move-on {
  44. top: 10px;
  45. opacity: 1;
  46. background-color: rgb(255, 255, 255);
  47. box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.5);
  48. }

友链居中

打开 _sass/_custom/custom.scss 文件,新增变量:

  1. //友链居中
  2. .links-of-blogroll-title {
  3. text-align: center;
  4. }

修改友链文本颜色

打开 _sass/_custom/custom.scss 文件,新增变量:

  1. //友链文本颜色
  2. //将链接文本设置为蓝色,鼠标划过时文字颜色加深,并显示下划线
  3. .post-body p a{
  4. text-align: center;
  5. color: #434343;
  6. border-bottom: none;
  7. &:hover {
  8. color: #5073b8;
  9. text-decoration: underline;
  10. }
  11. }

修改友链样式

打开 _sass/_custom/custom.scss 文件,新增变量:

  1. //修改友情链接样式
  2. .links-of-blogroll-item a{
  3. text-align: center;
  4. color: #434343;
  5. border-bottom: none;
  6. &:hover {
  7. color: #5073b8;
  8. text-decoration: underline;
  9. }
  10. }

自定义页脚的心样式

打开 _sass/_custom/custom.scss 文件,新增变量:

  1. // 自定义页脚的心样式
  2. @keyframes heartAnimate {
  3. 0%,100%{transform:scale(1);}
  4. 10%,30%{transform:scale(0.9);}
  5. 20%,40%,60%,80%{transform:scale(1.1);}
  6. 50%,70%{transform:scale(1.1);}
  7. }
  8. #heart {
  9. animation: heartAnimate 1.33s ease-in-out infinite;
  10. }
  11. .with-love {
  12. color: rgb(255, 113, 168);
  13. }

设置头像边框为圆形框

打开 _sass/_common/components/sidebar/sidebar-author.scss 文件,新增变量:

  1. .site-author-image {
  2. display: block;
  3. margin: 0 auto;
  4. padding: $site-author-image-padding;
  5. max-width: $site-author-image-width;
  6. height: $site-author-image-height;
  7. border: $site-author-image-border-width solid $site-author-image-border-color;
  8. /* 头像圆形 */
  9. border-radius: 80px;
  10. -webkit-border-radius: 80px;
  11. -moz-border-radius: 80px;
  12. box-shadow: inset 0 -1px 0 #333sf;

特效:鼠标放置头像上旋转

打开 _sass/_common/components/sidebar/sidebar-author.scss 文件,新增变量:

  1. /* 设置循环动画 [animation: (play)动画名称 (2s)动画播放时长单位秒或微秒 (ase-out)动画播放的速度曲线为以低速结束
  2. (1s)等待1秒然后开始动画 (1)动画播放次数(infinite为循环播放) ]*/
  3. /* 鼠标经过头像旋转360度 */
  4. -webkit-transition: -webkit-transform 1.0s ease-out;
  5. -moz-transition: -moz-transform 1.0s ease-out;
  6. transition: transform 1.0s ease-out;
  7. }
  8. img:hover {
  9. /* 鼠标经过停止头像旋转
  10. -webkit-animation-play-state:paused;
  11. animation-play-state:paused;*/
  12. /* 鼠标经过头像旋转360度 */
  13. -webkit-transform: rotateZ(360deg);
  14. -moz-transform: rotateZ(360deg);
  15. transform: rotateZ(360deg);
  16. }
  17. /* Z 轴旋转动画 */
  18. @-webkit-keyframes play {
  19. 0% {
  20. -webkit-transform: rotateZ(0deg);
  21. }
  22. 100% {
  23. -webkit-transform: rotateZ(-360deg);
  24. }
  25. }
  26. @-moz-keyframes play {
  27. 0% {
  28. -moz-transform: rotateZ(0deg);
  29. }
  30. 100% {
  31. -moz-transform: rotateZ(-360deg);
  32. }
  33. }
  34. @keyframes play {
  35. 0% {
  36. transform: rotateZ(0deg);
  37. }
  38. 100% {
  39. transform: rotateZ(-360deg);
  40. }
  41. }

Bug 修复

打赏文字抖动修复

打开 _sass/_common/components/post/post-reward.scss 文件,然后注释其中的函数 wechat:hoveralipay:hover ,如下:

  1. /*
  2. #wechat:hover p{
  3. animation: roll 0.1s infinite linear;
  4. -webkit-animation: roll 0.1s infinite linear;
  5. -moz-animation: roll 0.1s infinite linear;
  6. }
  7. #alipay:hover p{
  8. animation: roll 0.1s infinite linear;
  9. -webkit-animation: roll 0.1s infinite linear;
  10. -moz-animation: roll 0.1s infinite linear;
  11. }
  12. */

修改文章底部的带#号标签

打开 _includes/_macro/post.html 文件,搜索 rel="tag"># ,将 # 换成 <i class="fa fa-tag"></i>

  1. <div class="post-tags">
  2. {% for tag in post.tags %}
  3. {% assign tag_url_encode = tag | url_encode | replace: '+', '%20' %}
  4. <a href="{{ '/tag/#/' | relative_url | append: tag_url_encode }}" rel="tag"><i class="fa fa-tag"></i> {{ tag }}</a>
  5. {% endfor %}
  6. </div>

插件配置

阅读次数统计(LeanCloud)

  • 请查看 为NexT主题添加文章阅读量统计功能

  • 打开 config.yml 文件,搜索 leancloud_visitors , 进行如下更改:

    1. leancloud_visitors:
    2. enable: true
    3. app_id: <app_id>
    4. app_key: <app_key>

    app_idapp_key 分别是 你的LearnCloud 账号的 AppIDAppKey

阅读次数美化

效果?:

  • 打开 _data/languages/zh-Hans.yml 文件,将 post 中的 visitors:阅读次数 改为:visitors: 热度

  • 打开 _includes/_macro/post.html 文件,搜索 leancloud-visitors-count ,在 <span></span> 之间添加

    1. <span id="{{ post.url | relative_url }}" class="leancloud_visitors" data-flag-title="{{ post.title }}">
    2. <span class="post-meta-divider">|</span>
    3. <span class="post-meta-item-icon">
    4. <i class="fa fa-eye"></i>
    5. </span>
    6. {% if site.post_meta.item_text %}
    7. <span class="post-meta-item-text">{{__.post.visitors}} </span>
    8. {% endif %}
    9. <span class="leancloud-visitors-count"></span>
    10. <span></span>
    11. </span>

在网站底部加上访问量

效果?:

  • 打开 _includes/_partials/footer.html 文件,在 <div class="copyright" > 之前加入下面的代码:

    1. <script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
  • {% if site.copyright %} 之后加入下面的代码:

    1. <div class="powered-by">
    2. <i class="fa fa-user-md"></i><span id="busuanzi_container_site_uv">
    3. 本站访客数:<span id="busuanzi_value_site_uv"></span>
    4. </span>
    5. </div>

部分样式可参考我的博客?:Laugh’s Blog

参考文章:

Hexo+Next主题优化

hexo的next主题个性化教程:打造炫酷网站

参考博客:

DS Blog

Jekyll + NexT + GitHub Pages 主题深度优化的更多相关文章

  1. 使用jekyll在GitHub Pages上搭建个人博客【转】

    网上有不少资源,但大多是“授人以鱼”,文中一步一步的告诉你怎么做,却没有解释为什么,以及他是如何知道的.他们默认着你知道种种专业名词的含义,默认着你掌握着特定技能.你折腾半天,查资料,看教程,一步步下 ...

  2. hexo next主题深度优化(一),加入pjax功能。

    文章目录 背景: 进入正题 pjax初体验--instantclick 真正的pjax 第一步 第二步 第三步 第四步 专门基于hexo next主题的pjax(将丢失的js效果重现) 将下面讲到的提 ...

  3. hexo next主题深度优化(五),评论系统换成gittalk

    文章目录 背景: 开始: 新建comments_git.js 找到comments.swig在最后一个endif之前 引入代码 pjax加入gitalk 遇到的问题 所有的页面共享的一个评论issue ...

  4. hexo next主题深度优化(二),懒加载。

    文章目录 tip:没有耐心的可以直接看:正式在hexo next中加入懒加载(最下面) 废话 背景 懒加载简单介绍 引入js 重点!敲黑板了!!! 完善懒加载函数 懒加载函数可配置的参数 正式在hex ...

  5. hexo next主题深度优化(十一),next主题中加入scrollReveal.js,让文章随着鼠标的滚动,出现点小动作。

    文章目录 效果 scrollReveal简单介绍以及简单操作 参考文档: next主题中加入scrollReveal 给article标签添加属性 给底部的不蒜子添加属性 本地引入依赖并且编写启动函数 ...

  6. hexo next主题深度优化(七),cdn加速。

    文章目录 注: 正题: 免费cdn 收费cdn 个人博客:https://mmmmmm.me 源码:https://github.com/dataiyangu/dataiyangu.github.io ...

  7. hexo next主题深度优化(九),给博客加入主题,护眼主题,护眼色。

    文章目录 背景 效果 码 _layout.swig custom.styl eye.js 引用eye.js 直接引用 main.js pjax的函数中重写 个人博客:https://mmmmmm.me ...

  8. hexo next主题深度优化(八),微加速

    个人博客:https://mmmmmm.me 源码:https://github.com/dataiyangu/dataiyangu.github.io 通过不断地上网查资料,引用的js.css.图片 ...

  9. hexo next主题深度优化(四),自定义一个share功能,share.js。

    文章目录 背景: 开始: 引入资源: 代码 关键的一步 附:方便学习的小demo 一次成功后还出现上面的bug 结束 2018.12.23发现bug(读者可忽略) 个人博客:https://mmmmm ...

随机推荐

  1. Jenkins 报错合集

    目录 一.启动项目显示,没有接受许可之前不能够自动安装 二.明明配置了jdk但还是说找不到 三.jenkins-RestAPI调用出现Error 403 No valid crumb was incl ...

  2. 【划重点】Python遍历列表的四种方法

    一.通过for循环直接遍历 user1 = ["宋江","林冲","卢俊义","吴用"] for user in use ...

  3. Kubernetes-API Server

    前言 本篇是Kubernetes第十四篇,大家一定要把环境搭建起来,看是解决不了问题的,必须实战. Kubernetes系列文章: Kubernetes介绍 Kubernetes环境搭建 Kubern ...

  4. React Color使用

    需求 - 要在react项目中实现颜色获取器功能 解决方案 - 使用react-color 依赖 - git地址:https://github.com/casesandberg/react-color ...

  5. DKT模型及其TensorFlow实现(Deep knowledge tracing with Tensorflow)

    今年2月15日,谷歌举办了首届TensorFlow Dev Summit,并且发布了TensorFlow 1.0 正式版. 3月18号,上海的谷歌开发者社区(GDG)组织了针对峰会的专场回顾活动.本文 ...

  6. 【LeetCode】1182. Shortest Distance to Target Color 解题报告 (C++)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客:http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 字典+二分查找 日期 题目地址:https://lee ...

  7. 【LeetCode】292. Nim Game 解题报告(Java & Python)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 日期 题目地址:https://leetcode.c ...

  8. 【LeetCode】361. Bomb Enemy 解题报告(C++)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客:http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 暴力搜索 日期 题目地址:https://leetco ...

  9. 【LeetCode】375. Guess Number Higher or Lower II 解题报告(Python)

    [LeetCode]375. Guess Number Higher or Lower II 解题报告(Python) 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://f ...

  10. The Luckiest number(hdu2462)

    The Luckiest number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Othe ...