首页预览加入图片
在根目录下的images文件夹加入图片
1 | --- |
Hexo-lazyload-image图片懒加载
下载插件
npm install hexo-lazyload-image –save
修改_config.xml
1 | lazyload: |
文章插入图片
1. 把主页配置文件_config.yml 里的post_asset_folder:这个选项设置为true
在你的hexo目录下执行这样一句话npm install hexo-asset-image –save,这是下载安装一个可以上传本地图片的插件
等待一小段时间后,再运行hexo n “xxxx”来生成md博文时,/source/_posts文件夹内除了xxxx.md文件还有一个同名的文件夹;
最后在xxxx.md中想引入图片时,先把图片复制到xxxx这个文件夹中,然后只需要在xxxx.md中按照markdown的格式引入图片:
![你想输入的替代文字](图片名.jpg)
例如
![loading](background.jpg)
result:
Next主题图片浏览放大功能fancybox
1 | Step1: |
Hexo NexT主题添加点击爱心效果
创建js文件
在/themes/next/source/js/src下新建文件 clicklove.js ,接着把该链接下的代码拷贝粘贴到 clicklove.js 文件中。
代码如下:
1 | !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); |
修改_layout.swig
在\themes\next\layout_layout.swig文件末尾添加:
1 | <!-- 页面点击小红心 --> |
Next网站标题栏颜色
打开themes/next/source/css/_custom/custom.styl,在里面新增如下代码:
1 | .site-meta { |
博客背景图片
打开上述相同文件
1 | body { |
背景虚化
1 | // 修改主体透明度 |
添加资源链接菜单
(1) hexo new page "resources"
(2) 编辑resources文件夹下的md页面,将类型设置为resources,主题将自动为这个页面显示所有分类。
1 | title: resources |
menu:
resources: /resources || download
1 |
|
阅读全文设置
在网站首页只显示每篇文章的部分内容,不要全部内容都展示出来。
解决
要解决这个问题有两个方法:一是修改 _config.yml 文件设置,而是直接在你的 md 中加一句代码即可。
第一种方法
用文本编辑器打开 themes/next 目录下的 _config.yml 文件,找到这段代码:
Automatically Excerpt. Not recommend.
Please use in the post to control excerpt accurately.
1 | auto_excerpt: |
第二种方法
在你写 md 文章的时候,可以在内容中加上 ,这样首页和列表页展示的文章内容就是 之前的文字,而之后的就不会显示了。
效果
上面两种方式展示出来的效果是不一样的。
第一种修改 _config.yml 文件的效果是会格式化你文章的样式,直接把文字挤在一起显示,最后会有 …
标签云
位置:\blog\themes\next\layout\page.swig
原来:
1 | {{ tagcloud({min_font: theme.tagcloud.min, max_font: theme.tagcloud.max, amount: theme.tagcloud.amount, color: true, start_color: theme.tagcloud.start, end_color: theme.tagcloud.end}) }} |
修改成:(else)
1 | {% if not theme.tagcloud %} |
与主题样式一致的 404 页面
new page
1 | cd <blog-path> #定位到 Hexo 博客目录 |
index.md
1 | --- |
使用hexo-neat插件压缩页面以提高响应速度
安装hexo-neat插件
npm install hexo-neat --save
在站点配置文件中添加配置
下边是我自己站点的相关配置,直接添加到站点配置文件_config.yml的末尾就可以。可以安装自己的需求去自定义那些文件需要压缩,主要是有些js可能压缩后会失效。
1 | # 博文压缩 |
菜单上显示数目
在next的主题配置文件中找到下面内容,设置为true即可
1 | menu_settings: |
Next主题代码块加入复制功能
在Next主题的配置文件,将copy_button打开
1 | codeblock: |
修改侧边栏宽度
1 | # Manual define the sidebar width. If commented, will be default for: |
Hexo博客NexT主题下添加文章边框阴影效果
1 | .post { |
保留上次阅读时候的位置
1 | # Automatically saving scroll position on each post / page in cookies. |
界面对齐方式
1 | # Set the text alignment in the posts. |