注册Gitee账户

https://gitee.com

创建仓库

图片

这里需要注意,仓库名称及路径最好设置为Gitee用户名
这样j就可以获得一个xxx.gitee.io的域名

将项目转为Pages

  1. 选择服务->Gitees
    图片
  2. 分支设置为master
  3. 部署目录为/

安装Git

点击下载

安装node.js

点击下载

npm切换国内源

1
2
3
npm config set registry https://registry.npm.taobao.org
#或者将npm替换位cnpm使用
npm install -g cnpm --registry=https://registry.npm.taobao.org

部署HEXO

1
npm install hexo-cli -g

初始化博客框架

1
2
hexo init gitee_blog
#gitee_blog是本地文件夹名

Hexo博客目录结构

  • _config.yml : 全局配置文件,部署完后需要修改下这里面的配置。

  • package.json:数据库保存在这个里面。

  • source: md格式的源文件都在这里面。

  • public: 这个文件夹还没有生成,网页都在这里面。

  • themes:博客的主题保存路径,每个文件夹一个主题。

启动Hexo服务

1
2
3
PS C:\Users\oneda\Documents\Blog\Gitee-blog\themes> hexo server
INFO Start processing
INFO Hexo is running at http://localhost:4000 . Press Ctrl+C to stop.

到此便以完成hexo得本地搭建,访问http://localhost:4000即可看到默认主题的hexo博客

客制化

切换主题

git主题到theme目录下

主题到这里下载

1
2
3
4
5
6
7
PS C:\Users\oneda\Documents\Blog\Gitee-blog\themes>git clone https://github.com/blinkfoxhexo-theme-matery.git
Cloning into 'hexo-theme-matery'...
remote: Enumerating objects: 80, done.
remote: Counting objects: 100% (80/80), done.
remote: Compressing objects: 100% (62/62), done.
Receiving objects: 100% (4050/4050), 11.52 MiB | 14.00 KiB/s, done.
Resolving deltas: 100% (2626/2626), done.

打开Gitee-blog目录下的_config.yml文件

theme:后的名称改为themes目录下已有的主题名即可

1
theme: hexo-theme-matery

新建页

about

  • about是用来展示个人信息的页面
1
2
PS C:\Users\oneda\Documents\Blog\Gitee-blog> hexo new page "about"
INFO Created: ~\Documents\Blog\Gitee-blog\source\about\index.md

修改/source/categories/index.md内容

1
2
3
4
5
6
---
title: categories
date: 2018-09-30 17:25:30
type: "about"
layout: "about"
---

参照以上方法依次新建以下文件

tags 展示所有标签的页面

categories 展示所有分类的页面

contact 展示留言板信息的页面(可选)

friends 展示友情连接的页面(可选)

大概设置如上,具体详细参数依依百度

_config.yml文件配置

1
2
3
4
5
6
7
8
9
10
11
url: 这里写上网站住URL
//如我得gitee项目地址为https://oneda1sy.gitee.io/oneda1sy,这里填https://oneda1sy.gitee.io/即可
root: /
language: zh-CN //这里修改为中文

deploy:
type: git
repo: https://gitee.com/oneda1sy/oneda1sy.git
//项目的git地址
branch: master

上传到Gitee

再网站目录中

1
2
3
hexo clean
hexo g
hexo d

执行完后直接访问xxx.gitee.io便可以看到自己的博客了