1. Github Page

  • 创建仓库:创建youname.github.io的仓库;
  • 打开Github Page:默认会开启该功能,测试访问地址;
  • 配置SSH KEY:使用命令ssh-keygen -t rsa -C "email",并配置到Github上;
  • 检出工程:检出该工程;

2. Hexo

环境安装:

1
2
3
4
5
$ npm install -g hexo # 安装
$ npm install hexo-deployer-git --save # 安装Git 插件
$ hexo init # 初始化
$ hexo g # 生成
$ hexo s # 启动服务

修改配置:

1
2
3
4
5
6
7
8
9
10
11
12
13
/* _config.yml */
/* 部署配置 */
deploy:
type: git
repository: git@github.com:[youname]/[youname].github.io.git
branch: master
/* 站点信息/语言 */
title: 站点名称
subtitle:
description:
author: 作者
language: zh-CN
timezone:

常用命令:

1
2
3
4
5
6
7
8
hexo n "postName" #新建文章
hexo n page "pageName" #新建页面
hexo g #生成静态页面至public目录
hexo s #开启预览访问端口(默认端口4000,'ctrl + c'关闭server)
hexo d #部署到GitHub
hexo help # 查看帮助
hexo version #查看Hexo的版本
hexo d -g #生成并上传

文章格式

1
2
3
4
5
6
7
8
---
title: #文章标题
date: #发布时间
categories: #分类
tags: #文章标签,[tag1,tag2,tag3]
description: #文章摘要
---
# 以下是正文

3. Hexo Theme - Maupassant

安装主题:

1
2
3
$ git clone https://github.com/tufu9441/maupassant-hexo.git themes/maupassant
$ npm install hexo-renderer-jade@0.3.0 --save
$ npm install hexo-renderer-sass --save

配置主题:

1
2
/* _config.yml */
theme:maupassant

语法高亮:

1
2
3
4
5
6
/* _config.yml */
highlight:
enable: true
auto_detect: true
line_number: true
tab_replace:

参考文档

使用hexo+github搭建免费个人博客详细教程
大道至简——Hexo简洁主题推荐