the creation of this site

序言

仅以本篇唠叨地记录一下本站的建立。

很久以前我在新浪有过博客,后来在wordpress、csdn陆续又有过,但别人的总是很蛋疼,于是后来搬迁到了自己服务器上的wordpress。Everything seems ok, but…

wordpress对外部的依赖实在让我蛋疼,备份一下配这配那的,有一天我的服务器格了,然后一切就悲剧了,我也懒得去google drive上找几个月前的备份了。经过一番查找,觉得静态的hexo很符合我的要求,而且markdown啊!再怎么我还能练练写README.md是不是?

于是下文就是唠唠叨叨的实际建立过程了。

How am i built

前提

已经安装了node, xcode, git
配好了github ssh
在github建立了username.github.io的repo

安装

1
2
3
4
5
6
7
8
9
10
11
# 安装淘宝的npm镜像工具cnpm
npm install -g cnpm --registry=https://registry.npm.taobao.org
# 于是可以直接用cnpm了
cnpm install -g hexo-cli
# 安装后去你的开发目录里建文件夹存放blog吧
hexo init blog
cd blog
cnpm install
cnpm install hexo-deployer-git --save
hexo generate
hexo deploy

deploy后上自己的github.io看看,是不是已经可以访问了?

配置

下一步就是把自己的域名和github.io绑定了,可以看到
http://blog.zhaiyifan.cn & http://markzhai.github.io
最后都会跳转到我的blog域名下。

这个就是配置的问题了, _config.yml:

1
2
# URL
url: http://blog.zhaiyifan.cn

url配成自己的域名,然后在域名商的解析中,把自己的域名解析到username.github.io

然后!不要急,在generate和deploy前,hexo还需要CNAME

1
2
3
cd source
echo blog.zhaiyifan.cn > CNAME
cd ..

Done,generate和deploy后,大功告成。

主题

如果想要点好看的主题怎么办呢?作为一个宅男,我当然想要一个二次元的主题了,下面这两个站点可以看到一些主题,大部分都有demo展示
https://github.com/hexojs/hexo/wiki/Themes
https://hexo.io/themes/

于是我就一眼相中了hexadillax

1
git clone https://github.com/XadillaX/hexadillax themes/hexadillax

后把hexadillax/_config.sample.yml的内容拷贝到_config.yml,填一下,比如多说的二级域名,然后在source下对应文件夹创建两个文件
tags/index.md:

1
2
3
layout: tags
title: tags
---

categories/index.md:

1
2
3
layout: categories
title: categories
---

Done again, generate, deploy, check it!

坚持原创技术分享,您的支持将鼓励我继续创作!