hexo部署

安装前提
  • Node.js https://nodejs.org/en/
wget https://nodejs.org/dist/v10.4.0/node-v10.4.0-linux-x64.tar.xz
tar xvf node-v10.4.0-linux-x64.tar.xz -C /opt/laohulab
cd /opt/laohulab
mv node-v10.4.0-linux-x64 node-10.4.0
export PATH="/opt/laohulab/node-10.4.0/bin:$PATH"
  • Git

本地部署环境为 CentOS Linux release 7.3.1611 (Core),Git已默认安装,版本为 git version 1.8.3.1,若未安装可以通过YUM安装 yum install git-core

Git版本若为1.7版本,通过如下命令安装git会出现如下错误
curl https://raw.github.com/creationix/nvm/master/install.sh | sh

Please upgrade your git client.
GitHub.com no longer supports git over dumb-http: https://github.com/blog/809-git-dumb-http-transport-to-be-turned-off-in-90-days

安装hexo
npm install -g hexo-cli
cd /opt/laohulab
hexo init blog #初始化,名字任意
hexo --debug -i 192.168.10.27 s #debug模式启动
安装hexo常用插件
npm install hexo-generator-index --save #索引
npm install hexo-generator-archive --save #归档
npm install hexo-migrator-rss --save #RSS
npm install hexo-generator-feed --save #RSS
npm install hexo-generator-searchdb --save #搜索
npm install hexo-generator-search --save #搜索
npm install hexo-wordcount --save #字符统计
npm install hexo-admin --save #后台管理
npm install hexo-generator-sitemap --save --registry https://registry.npm.taobao.org #sitemap
npm install hexo-pdf --save --registry https://registry.npm.taobao.org #pdf插件
hexo-admin配置
点击setup

配置账号相关

配置_config.yml

将自动生成配置信息插入站点配置文件_config.yml,重启hexo服务即可!

配置主页标签

hexo new page tags #标签
hexo new page categories #分类
hexo new page commonweal #公益404
hexo new page about #关于
hexo new page schedule #日程

默认未创建相关标签主页,点击会出现404错误,创建即可!

hexo主题修改
安装
cd /opt/laohulab/blog
git clone https://github.com/iissnan/hexo-theme-next /themes/next

官网:http://theme-next.iissnan.com

启用next主题

Next主题个性化配置
启用Gemini

4种模式,个人倾向于Gemini模式,以下的修改均基于Gemini

启用字符统计

修改字体

启用站点统计

启用本地搜索

关闭fancybox功能

启用文章meta信息

修改文章显示时间

vim themes/next/layout/_macro/post.swig
默认仅显示日期,不显示时间,进行修改!

阅读量增加中文

vim themes/next/layout/_macro/post.swig

文章统计增加中文

vim themes/next/layout/_macro/post.swig

修改表格显示宽度和字体大小

vim themes/next/source/css/_variables/base.styl

修改正文显示宽度

vim themes/next/source/css/_variables/Gemini.styl

修改tag标签显示

vim themes/next/layout/_macro/post.swig
将默认#号修改为

其他设置

vim themes/next/source/css/_custom/custom.styl 新增如下配置!

//表头增加背景色
table th{
background:#f0f8ff;
}

//水平线由默认3px变更为2px
hr{
height: 2px;
}

//代码块预览显示,需要修改hexo配置文件,取消显示行号
.highlight .code pre {
white-space: pre-wrap;
word-wrap: break-word;
width: auto
}

//取消默认灰色背景,修改为绿色背景,文字白色
code {
background: #3fb618;
color: #fff;
}

//图片默认居中,修改inline-block,靠左对齐
img {
display: inline-block;
}

0%