您的位置:首页 > 编程语言

Hexo + Github Pages 搭建个人博客

2016-12-05 02:43 555 查看
https://hexo.io/zh-cn/docs/commands.html
https://hexo.io/zh-cn/docs/commands.html


Hexo + Github Pages 搭建个人博客

2月 06, 2016 发布在 Hexo

1. 安装Homebrew

1
2
3
4
5

# Install Homebrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" 
# Check
brew --version

2. 安装Node.js & npm

1
2

# Install Node.js
brew install node

3. Hexo牛刀小试

1
2
3
4
56
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

# 安装hexo-cli
npm install hexo-cli -g

# 使用Hexo初始化你的Blog目录
mkdir hexo
cd /Users/tiansj/hexo
hexo init blog   # INFO Cloning hexo-starter to ~/hexo/blog
cd blog
npm install

# 启动Server,访问127.0.0.1:4000
hexo server

# 创建一个新文章
hexo new "Hello Hexo"
#会在blog/source/_posts下创建Hello-Hexo.md,剩下的写作可以选择任何Markdown工具自由写作

# 生成静态文件(blog/public)
hexo generate
hexo server
# 再次启动,可以看到写做新文章了

4. 设置主题,这里用的是[hexo-theme-tranquilpeak](https://github.com/LouisBarranqueiro/hexo-theme-tranquilpeak)

# 下载喜欢的主题,注意这个主题需要grunt build后才能应用,如果你不想折腾,直接下载生产版本,见上面站点 Quick start 第一项下载最新版本
git clone https://github.com/tianshaojie/hexo-theme-tranquilpeak.git themes/tranquilpeak

# 修改blog/_config.yml (hexo clean/generate/server)新主题已应用
theme: tranquilpeak

# 个性化自己的信息
/blog/theme/tranquilpeak/__config.yml

5. 生成导航页面,分类页、标签页、文章列表页

# 在~/hexo/blog/下执行命令
hexo new page "all-categories"
hexo new page "all-tags"
hexo new page "all-archives"

6. 编辑/source/各个目录下的index.md,重启后导航即生效

---
title: "all-categories"
layout: "all-categories"
comments: false
---

---
title: "all-tags"
layout: "all-tags"
comments: false
---

---
title: "all-archives"
layout: "all-archives"
comments: false
---

7. 配置Deploy,自动部署到Github上

# 先生产你的GitHub Pages页面
# 修改blog/_config.yml中的deploy项

deploy:
type: git
repository: git@github.com:username/username.github.com.git
branch: master

# 在~/hexo/blog下执行
npm install hexo-deployer-git --save

# 自动部署命令,然后华丽丽的看你的网站吧
hexo deploy

8. OK,自由的写文章

1. hexo new "",新建文章
2. ~/hexo/blog/source/_post,下找到对应.md文件,自由编辑
3. hexo g,生成静态html文件
4. hexo s,部署到线上

9. 帮助链接
Hexo中文官方文档
hexo-theme-tranquilpeak主题文档
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: