前言
目前网上的很多平台都提供了博客功能,如csdn,51cto,cnblog,iteye等等,只要你想写博客,这些平台都可以选择。只需注册个帐号,就可以写博客,实现比较简单,但是局限性也很大,风格千篇一律,没有个性化,扩展也稍麻烦。并且,广告很多,这点很受不了。在此选择了hexo+next+github建立个人的博客平台。
准备
github:https://github.com/dwj999
发布平台:centos6.5 x86_64
发布工具:git
编写平台:windows7 x86_64
编写工具:有道云笔记
框架:hexo
主题:next
安装Node.js
操作系统为centos6.5,首先删除旧版本
1 | yum -y remove nodejs |
node使用最新版本,下载源码包
1 | wget https://nodejs.org/dist/v8.1.4/node-v8.1.4-linux-x64.tar.xz |
配置系统环境变量
1 | vim /etc/profile |
安装Git(已安装可跳过)
1 | yum install git-core |
安装Hexo
这里以我的github为例,地址为:https://github.com/dwj999
1 | 创建目录 |
安装插件
1 | npm install hexo-generator-index --save |
目录结构
1 | |-- _config.yml |
目录结构说明
1 | _config.yml |
部署到GitHub
站点配置
修改Hexo站点配置文件/hwdata/dwj999/_config.yml,以下为例
1 | # Site |
github创建项目
仓库的名字必须和你的帐号对应,比如我的github地址:https://github.com/dwj999 新建仓库名为dwj999.github.io,因我的项目已创建,此为演示,故有提醒,可忽略
git配置
1 | git config --global user.email "dwj999@163.com" |
添加key
打开github地址:https://github.com/settings/ssh,打开ssh keys,添加key
代码上传
1 | # linux编译 |
站点访问,左面菜单和主题已经配置过
主题和配置文件
切换到站点目录,下载主题代码
1 | cd /hwdata/dwj999 |
配置主题
1 | vim _config.yml |
主题和第三方服务说明
官方文档很详情
请参考:
http://theme-next.iissnan.com/getting-started.html
http://theme-next.iissnan.com/theme-settings.html
http://theme-next.iissnan.com/third-party-services.html
发布文章
由于hexo支持markdown写文章,并且我使用的是windows机器,代码发布在linux机器上,所以选择了有道云笔记的markdown笔记来写文章,虽然语法支持有缺陷,但是以前习惯了使用有道云,没有使用其他工具,像Cmd Markdown的在线编辑器也不错。
1 | hexo new "hexo next 在github上搭建个人博客" |