hexo系列教程:(四)hexo博客的优化技巧
2014-12-29 00:40
295 查看
hexo系列教程:(四)hexo博客的优化技巧
转载自http://zipperary.com/2013/05/30/hexo-guide-4/上一节中我们已经学会了用hexo发布博客,这里再介绍一些小技巧对博客站点进行优化,实现更加丰富的功能。
添加“多说”评论
hexo默认使用国外比较流行的disqus,不过,按照“因地制宜”的原则,我们修改为国内用的多又好用的“多说”评论系统。步骤非常简单:在多说进行注册,获得通用代码。
将通用代码粘贴到
themes\light\layout\_partial\comment.ejs里面,如下:
1 2 3 4 5 | <% if ( page.comments){ %> <section id="comment"> 通用代码 </section> <% } %> |
添加『页面导航』
在刚才添加「多说」评论的文件中,加入一段代码,如下:1 2 3 4 56 | <% if ( page.comments){ %> <nav id="pagination" > <% if (page.prev) { %> <a href="<%- config.root %><%- page.prev.path %>" class="alignleft prev" ><%= __('prev') %></a> <% } %> <% if (page.next) { %> <a href="<%- config.root %><%- page.next.path %>" class="alignright next" ><%= __('next') %></a> <% } %> <div class="clearfix"></div> </nav> <section id="comment"> |
添加“百度分享”
到百度分享获得代码,在themes/light/layout/_partial/article.ejs中,将
<%-partial('post/share')%>删掉,替换为百度分享的代码。
添加小图标
在themes/light/layout/_partial/head.ejs里将
<link href="<%- config.root %>favicon.png" rel="icon">替换为
<link href="<%- config.root %>favicon.ico" rel="icon" type="image/x-ico">。将favicon.ico图标文件放在source目录下。制作图标的网站,http://www.faviconer.com。
添加分类、标签云widget
很简单,在themes/light/_config.yml中,添加如下:
1 2 3 | widgets: - category - tagcloud |
添加友情链接widget
在themes/light/layout/_widget中新建名为
blogroll.ejs的文件,编辑内容如下:
1 2 3 4 56 | <div class="widget tag"> <h3 class="title">友情链接</h3> <ul class="entry"> <li><a href="http://zipperary.com/" title="Zippera's Blog">Zippera</a></li> </ul> </div> |
themes/light/_config.yml中,添加如下:
1 2 | widgets: - blogroll |
生成post时默认生成categories配置项
在scaffolds/post.md中,添加一行
categories:。同理可应用在
page.md和
photo.md。
添加新浪微博widget(微博秀)
去新浪微博开放平台设置和生成微博秀代码。在
themes/light/layout/_widget中新建名为
weibo.ejs的文件,将刚才的代码直接保存到这里。
在
themes/light/_config.yml中,添加如下:
1 2 | widgets: - weibo |
导航栏添加”关于”
hexo new page "about"
到
source/about/index.md编辑内容。
在
themes/light/_config.yml中,添加如下:
1 2 | menu: 关于: /about |
主页文章显示摘要
编辑md文件的时候,在要作为摘要的文字后面添加<!--more-->即可。
优化是无止境的,今天先写这些。
相关文章推荐
- hexo系列教程:(五)hexo博客的优化技巧续
- Hexo系列3:博客优化
- Hexo系列教程之一:hexo-github搭建独立博客
- hexo系列教程:(三)hexo博客的配置、使用
- Hexo系列教程之三:next主题的配置和优化
- Hexo系列教程之一:hexo+github搭建独立博客
- Hexo系列教程之四:hexo的配置和优化
- Hexo系列教程之五:hexo博客同时托管在github和coding
- [转]ltra Fractal教程系列14——学习基础技巧06——同步位置
- OO系统设计师之路--分析模型系列(3)--分析模型的调整和优化[从老博客搬家至此]
- OO系统设计师之路--分析模型系列(3)--分析模型的调整和优化[从老博客搬家至此]
- Aptana使用技巧—Aptana2.0系列教程
- [转]Ultra Fractal教程系列13——学习基础技巧05——将图像放大
- 如何使用WordPress建立博客垃圾站在线赚钱 系列教程1:简介
- Web攻防系列教程之跨站脚本攻击和防范技巧详解
- Windows7的优化技巧之启动“高性能”设置(图文教程)
- LNMP系列教程之 SSL安装WordPress博客(程序下载与安装)
- [转]Ultra Fractal教程系列16——学习基础技巧08——使用渐变
- [转]Ultra Fractal教程系列15——学习基础技巧07——添加外着色
- 博客优化、收录、RSS技巧