CentOS使用hexo部署gitee pages

示例页面

一、创建gitee仓库

firefox https://gitee.com/

 

二、部署软件

1.切换为国内阿里yum源

# 备份原有repo文件
tar -zcf /etc/yum.repos.d/old.tgz /etc/yum.repos.d/
# 删除原repo文件
rm -f /etc/yum.repos.d/*.repo
# 下载阿里基本源
curl http://mirrors.aliyun.com/repo/Centos-7.repo -o /etc/yum.repos.d/Centos-Base.repo
# 下载阿里epel源
curl http://mirrors.aliyun.com/repo/epel-7.repo -o /etc/yum.repos.d/Centos-epel.repo
# 清理并显示已配置源
yum clean all && yum repolist

2.部署nodejs

[root@gitee ~]# yum -y install nodejs    #安装nodejs
[root@gitee ~]# node -v                  #查看node版本
v6.16.0
[root@gitee ~]# npm -v                   #查看npm版本
3.10.10

3.部署git

             9d4b6f720b337b905ccf0c9d00c810201cd.jpg

[root@gitee ~]# yum -y install git                                         #安装git
[root@gitee ~]# git --version                                              #查看git版本
git version 1.8.3.1

git全局配置:
[root@gitee ~]# git config --global user.name "xinsui1314x"                #gitee的用户名
[root@gitee ~]# git config --global user.email "xinsui1314x@qq.com"        #gitee的邮箱

clone仓库:
[root@gitee ~]# git clone https://gitee.com/xinsui1314x/xinsui1314x.git    #克隆项目
[root@gitee ~]# cd xinsui1314x/                                            #进入克隆的项目

4.部署hexo

[root@gitee xinsui1314x]# npm -g install hexo                         #安装hexo
[root@gitee hexo]# hexo --version                                     #查看hexo信息
hexo: 3.8.0
hexo-cli: 2.0.0
os: Linux 3.10.0-693.el7.x86_64 linux x64
http_parser: 2.8.0
node: 6.16.0
v8: 5.1.281.111
uv: 1.27.0
zlib: 1.2.7
ares: 1.10.1-DEV
icu: 50.1.2
modules: 48
napi: 3
openssl: 1.0.2k-fips

[root@gitee xinsui1314x]# mkdir hexo                                 #在克隆的项目创建hexo目录
[root@gitee xinsui1314x]# cd hexo/                                   #进入目录
[root@gitee hexo]# hexo init                                         #初始化hexo
[root@gitee hexo]# npm install hexo-deployer-git --save              #安装hexo插件,自动配置到gitee

[root@gitee hexo]# ls -A1                                  #查看hexo目录结构
_config.yml        #站点的配置文件
db.json            #文件
.deploy_git        #由hexo g命令自动生成
.gitignore         #推送时忽略的文件
node_modules       #安装包目录,执行npm install命令自动生成
package.json       #安装包的名称
public             #由hexo g命令生成的静态网页目录
scaffolds          #文章的模板
source             #博客文章的.md文件
themes             #存放主题的文件夹

5.clone主题(可选,hexo提供了默认主题)

[root@gitee hexo]# firefox https://hexo.io/themes/    #hexo的主题网站
将主题存放在theme文件夹中

 

三、部署网站

1.修改站点配置文件

151177730f063b2c2b4b068bffd711f66ad.jpg

[root@gitee hexo]# vim _config.yml 
:set nu
  5 # Site
  6 title: gitee             #标题
  7 subtitle: pages测试       #子标题
  8 description:
  9 keywords:
 10 author: X                #作者
 11 language: zh-cn          #语言
 12 timezone:                #指定时区,默认使用浏览器时区

 14 # URL
 16 url: http://xinsui1314x.gitee.io/         #网站访问地址
 17 root: /                                   #根目录
 18 permalink: :year/:month/:day/:title/
 19 permalink_defaults:

 73 # Extensions
 74 ## Plugins: https://hexo.io/plugins/
 75 ## Themes: https://hexo.io/themes/
 76 theme: landscape                          #使用的主题,对应themes中的目录名

 80 deploy:
 81   type: git                                               #使用的自动配置方式
 82   repo: https://gitee.com/xinsui1314x/xinsui1314x.git     #项目地址,要与type对应
 83   branch: master                                          #使用的项目分支

2.生成页面并配置到gitee

[root@gitee hexo]# hexo clean && hexo g && hexo d
    # hexo clean       #清理生成的文件和缓存
    # hexo generate    #生成静态网页文件
    # hexo deploy      #部署到网站

3.gitee更新pages

d47f86d554d20237fcfda0424424e581121.jpg

4.访问pages

firefox http://xinsui1314x.gitee.io

70e77099f815291a1d0f4c1233c8a7db0c1.jpg

转载于:https://my.oschina.net/xinsui1314x/blog/3058581

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值