使用hexo+giuhub+nexo搭建博客

无意中看到使用hexo+github+next搭建的博客觉得很美观,支持markdown及其他扩展功能,于是花了点时间折腾了下。

准备工作

  • github账号
  • node.js 环境搭建
  • git使用
  • markdown语法

环境搭建

本地环境: win10
node -v
# v8.11.1
npm -v
# 5.6.0
hexo -v
# hexo: 3.7.1
# hexo-cli: 1.1.0
git --version
# git version 2.18.0.windows.1

nodejs,git安装过程及github.io的创建参考其他文章,git需要配置到如下输出可正常使用

ssh -T git@github.com
> Hi xxx! You've successfully authenticated, but GitHub does not provide shell access.

hexo安装使用
  1. 切换淘宝源
    npm config set registry https://registry.npm.taobao.org
  2. 安装使用hexo-cil
npm install -g hexo-cli
hexo init <folder>
cd <folder>
npm install
hexo g
hexo s
# 浏览器输入localhost:4000 ,可看到最初的hexo网站
# 此处命令可使用git-bash。exe 输入
  1. 安装部署到github.io的依赖
    npm install –save hexo-deployer-git
  2. 修改配置文件部署到github.io
#修改项目下的_config.yml文件
deploy:
type: git
repo: git@github.com:diaoyongbao/diaoyongbao.github.io.git #修改成自己的项目地址
branch: master
  1. 部署项目,访问项目地址
    hexo deploy
next安装使用
  1. 安装
cd your-hexo-site
git clone https://github.com/iissnan/hexo-theme-next themes/next
  1. 修改项目的配置文件启用
    theme: next

开启更多功能

官方网站上已经记录了很多功能,下面记录几个没有的

  1. 自动更换背景图片
# 配置文件 themes\next\source\css\ _custom\custom.styl
body {
background:url(https://source.unsplash.com/random/1600x900);
background-repeat: no-repeat;
background-attachment:fixed;
background-position:50% 50%;
#repeat:是否重复出现
#attachment:定义背景图片随滚动轴的移动方式
#position:设置背景图像的起始位置
}
  1. 字数统计
# 配置文件:themes/_config.yml
post_wordcount:
item_text: true
wordcount: true
min2read: true
totalcount: false
separated_meta: true
  1. 添加社交图标
# 配置文件:themes/_config.yml
social:
GitHub: https://github.com/diaoyongbao || github
E-Mail: mailto:dyb6884@gmail.com || envelope
  1. 点击爱心效果
    浏览器输入:http://7u2ss1.com1.z0.glb.clouddn.com/love.js
    拷贝所有代码,在/themes/next/source/js/src里面新建love.js,然后在/themes/next/layou/_layout.swig文件末尾添加以下代码:
<!-- 页面点击小红心 -->
<script type="text/javascript" src="/js/src/love.js"></script>

下载链接及参考文章

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值