本文将介绍如何通过GitHub Pages托管个人静态页面,博客所使用的框架为Hexo,Hexo主题为apollo

本地环境搭建

安装Git、Nodejs

安装配置Hexo

1
npm install -g hexo

创建文件夹,初始化Hexo

1
hexo init

安装apollo主题

安装依赖项(可能会有警告,但可以不管)

1
npm install --save hexo-renderer-jade hexo-generator-feed hexo-generator-sitemap hexo-browsersync hexo-generator-archive

下载主题文件

1
git clone https://github.com/chongshengsun/hexo-theme-apollo.git themes/apollo

修改_config.ymltheme配置项为apollo:

1
2
3
4
# Extensions
## Plugins: https://hexo.io/plugins/
## Themes: https://hexo.io/themes/
theme: apollo

apollo主题中的标签栏信息可以在./theme/apollo/_config.yml文件中修改。

GitHub Pages配置与部署Hexo

一开始打算使用Gitee的页面托管,但是使用该服务需要上传身份证照片,不仅麻烦还不方便写一些特殊技术,遂放弃。如何使用GitHub Pages可以参考这篇文章

配置好GitHub Pages就可以部署Hexo了.

部署Hexo

安装 hexo-deployer-git

1
npm install hexo-deployer-git --save

修改_config.yml配置文件

1
2
3
4
deploy:
type: git
repo: https://github.com/Big7ng/Big7ng.github.io.git
branch: master

在命令行输入如下命令完成部署

1
2
3
hexo clean
hexo generate
hexo deploy