0%

通过github pages使用hexo(next主题)搭建博客

安装hexo

前置安装Nodejs和git

1
2
3
4
5
npm install hexo-cli -g
hexo init blog
cd blog
npm install
hexo server

初始化git仓库

1
2
3
git init
git add .
git commit -m "init"

添加Next主题

fork hexo-theme-next

next 主题官方地址 https://github.com/theme-next/hexo-theme-next

fork到自己账号下

添加为hexo的submodule

blog目录

1
git submodule add https://github.com/tongluyang/hexo-theme-next themes/next

修改hexo主题为next

hexo配置文件/_config.yml

1
theme: next

提交

1
2
git add .
git commit -m "add hexo theme next"

修改next配置

next配置文件themes/next/_config.yml

1
2
3
4
5
6
7
8
9
# Schemes
#scheme: Muse
#scheme: Mist
#scheme: Pisces
scheme: Gemini

avatar:
# Replace the default image and set the url here.
url: https://avatars2.githubusercontent.com/u/25279149?s=120&v=4 #/images/avatar.gif

提交

1
2
3
4
5
6
cd themes/next
git add .
git commit -m "scheme and avatar"
cd ../..
git add themes/next
git commit -m "update submodule of next"

修改基本信息

hexo配置文件/_config.yml

1
2
3
4
5
6
7
8
9
10
11
12
# Site
title: TongLuyang's Blog
subtitle: ''
description: ''
keywords:
author: TongLuyang
language: zh-CN
timezone: Asia/Shanghai

# URL
## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
url: https://tongluyang.com

提交

1
2
git add .
git commit -m "update site info"

部署

如果要把源文件放在私有仓库,那么需要使用hexo-deployer-git

1
npm install hexo-deployer-git --save

修改hexo配置文件/_config.yml

1
2
3
4
5
deploy:
type: 'git'
repo: https://github.com/tongluyang/tongluyang.github.io.git
name: tongluyang
email: tongluyang@gmail.com

执行

1
hexo clean && hexo deploy