废弃, 博客迁移至Django+MySQL方案, 不再采用静态页面
brew update #通过brew进行安装
brew install npm
npm install -g hexo-cli
hexo init Blog #使用Blog作为网站目录
cd Blog
npm install
hexo server #访问 http://localhost:4000 查看demo
$ hexo new '博客部署小记'
$ hexo clean #清除缓存
# 发布:
$ hexo generate #生成静态文件
$ hexo server # 运行一个本地服务
Hexo is running at http://localhost:4000/. Press Ctrl+C to stop.
$ ssh-keygen -t rsa -C warn1667@gmail.com #在主目录下新建ssh key
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/oratun/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/oratun/.ssh/id_rsa.
Your public key has been saved in /Users/oratun/.ssh/id_rsa.pub.
The key fingerprint is:
$ cat ~/.ssh/id_rsa.pub #将公钥添加到github上(Settings: SSH&GPG keys)
ssh-rsa ****
$ git config --global user.email 'email'
$ git config --global user.name 'username'
$ npm install hexo-deployer-git
$ hexo clean
$ hexo g
$ hexo d #部署到github
# 可以简写为:
$ hexo g -d
此时可以通过oratun.github.io访问到博客
$ vi source/CNAME #在source目录下新建名为CNAME的文件
tongzhaohui.com #:wq 保存并退出
编辑站点配置文件_config.yml:
url: http://tongzhaohui.com
添加DNS解析:
记录类型 | 主机记录 | 记录值 |
---|---|---|
CNAME | www | oratun.github.io |
A | @ | 192.30.252.154 |
A | @ | 192.30.252.153 |
这里使用next主题
$ git clone https://github.com/iissnan/hexo-theme-next themes/next
1.安装sitemap:
npm install hexo-generator-sitemap --save
2.编辑站点配置文件,增加:
sitemap:
path: sitemap.xml
#编辑_config.yml
google_analytics: 填写Tracking ID
因为是静态博客, 所以使用第三方评论服务Disqus 注册后获得一个disqus name: tongzhaohui 将其填写到主题配置文件中.