Hexo基于GitHub的环境搭建

一、安装git客户端

git客户端下载地址:https://git-scm.com/downloads

二、安装nodejs

nodejs下载地址:https://nodejs.org/en/download/

三、安装Hexo

在本地新建一个文件Hexo(文件夹名可自取),进入文件夹,

鼠标右键git bash here,打开git控制台

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

浏览器访问

http://localhost:4000

四、搭建到Github

在GitHub新建一个项目例如我的RealChuan.github.io

命名标准xxx.github.io(其中xxx是你GitHub的username

Blog地址:https://realchuan.github.io

安装 hexo 的 git 插件

1
npm install hexo-deployer-git --save

修改Hexo/_config.yml

:后有一个空格,不然配置无效。

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

发布到GitHub

1
2
3
hexo clean
hexo generate
hexo deploy

五、配置Hexo

修改Hexo/_config.yml

:后有一个空格,不然配置无效。

基本信息配置

1
2
3
4
5
6
7
8
# Site
title: #标题
subtitle: #副标题
description: #描述
keywords: #关键词
author: #作者
language: #语言
timezone: #时区

六、写文章

1
hexo new "My New Post"

Tips

  1. //用以增加阅读全文;
  2. code //写代码