Hexo NexT 主题初体验

本文介绍如何配置NexT主题以实现RSS订阅、标签和分类页面的创建,并接入第三方服务如JiaThis分享、不蒜子计数及Valine评论系统。

简谈 NexT 主题的配置和第三方的服务的接入。

前言

前一篇完成了简单个人主页的搭建,然而,追求美的脚步和好奇心的滋生,难以遏制。

NexT 主题配置

NexT 主题配置官网文档,有详尽的配置,如设置 RSS、设置字体、设置代码高亮主题、侧边栏社交链接、开启打赏功能、友情链接、腾讯公益404等。

添加标签页面

# 进入站点根目录
$cd your-hexo-site
# 新建名为 tags 的页面
$hexo new page tags
复制代码

打开新建 tags 页面,将类型设为 tags。

title: 标签
date: 2017-12-30 12:39:04
type: "tags"
# 如果集成了评论服务,在标签页禁用该功能
comments: false
---
复制代码

编辑主题配置文件, 添加 tags 到 menu 中。

menu:
  home: /
  archives: /archives
  tags: /tags
复制代码

包含标签的文章

title: 标签测试文章
tags:
    - Testing
    - Another Tag
---
复制代码

添加分类页面

# 进入站点根目录
$cd your-hexo-site
# 新建名为 categories 的页面
$hexo new page categories
复制代码

打开新建 categories 页面,将类型设为 categories。

title: 标签
date: 2017-12-30 12:39:04
type: "categories"
# 如果集成了评论服务,在分类页禁用该功能
comments: false
---
复制代码

编辑主题配置文件, 添加 categories 到 menu 中。

menu:
  home: /
  archives: /archives
  tags: /tags
  categories: /categories
复制代码

包含分类的文章

title: 分类测试文章
categories: Testing
---
复制代码

添加 RSS 订阅

因为已经有成熟的依赖模块,所以添加 RSS 订阅很简单,进入站点目录

$ npm install hexo-generator-feed --save
复制代码

然后在主题配置目录配置文件中修改 RSS 配置,参见注释。

# Set rss to false to disable feed link.
# Leave rss as empty to use site's feed link.
# Set rss to specific value if you have burned your feed already.
rss:
复制代码

站点目录配置文件中,添加

rss: /atom.xml
feed:
  type: atom
  path: atom.xml
  limit: 20
复制代码

The last but not least,在站点目录配置文件中,配置 URL 为自己网站的地址。

# URL
## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
url: http://grackanil.top
复制代码

在上角添加fork me on github

提供两个获取样式的站点, GitHub RibbonsGitHub Corners 考虑到适配移动端适配,重叠于菜单按钮,我取的是 GitHub Corners 的右上角的样式。

# 修改 https://your-url 、fill:#151513; 和 color:#fff;
<a href="https://your-url" class="github-corner" aria-label="View source on Github"><svg width="80" height="80" viewBox="0 0 250 250" style="fill:#151513; color:#fff; position: absolute; top: 0; border: 0; right: 0;" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a><style>.github-corner:hover .octo-arm{animation:octocat-wave 560ms ease-in-out}@keyframes octocat-wave{0%,100%{transform:rotate(0)}20%,60%{transform:rotate(-25deg)}40%,80%{transform:rotate(10deg)}}@media (max-width:500px){.github-corner:hover .octo-arm{animation:none}.github-corner .octo-arm{animation:octocat-wave 560ms ease-in-out}}</style>
复制代码

粘贴样式代码至 themes/next/layout/_layout.swig 文件中<div class="headband"></div>下。

NexT 主题第三方服务接入

Jiathis,网站社会化工具。

注册 JiaThis,获取 uid。

配置主题配置文件 JiaThis。

# Share
# This plugin is more useful in China, make sure you known how to use it.
# And you can find the use guide at official webiste: http://www.jiathis.com/.
# Warning: JiaThis does not support https.
jiathis:
    #Get this uid from http://www.jiathis.com/
    uid: xxxxxx
复制代码

不蒜子,网站计数。

详细文档,配置好主题配置文件即可。

# Show PV/UV of the website/page with busuanzi.
# Get more information on http://ibruce.info/2015/04/04/busuanzi/
busuanzi_count:
  # count values only if the other configs are false
  enable: true
  # custom uv span for the whole site
  site_uv: true
  site_uv_header: <i class="fa fa-user"></i>
  site_uv_footer:
  # custom pv span for the whole site
  site_pv: true
  site_pv_header: <i class="fa fa-eye"></i>
  site_pv_footer:
  # custom pv span for one page only
  page_pv: true
  page_pv_header: <i class="fa fa-file-o"></i>
  page_pv_footer:
复制代码

Valine

Valine是一款基于leancloud的快速、简洁且高效的无后端评论系统。可以查看详细的 Valine 文档

七牛云,作为文章图片对象存储。

考虑到便于迁移博客,图床必须要,七牛访问速度快,支持日志,防盗链和水印。 免费用户有10GB流量/每月+总空间10GB+PUT/DELETE 10万请求+GET 100万请求,对于个人主页足够了,另外,可以邀请好友获得奖励。这是我的邀请:)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值