centos部署hexo并上传到github

1)环境搭建,安装Node.js
2)安装EPEL库 yum install epel-release -y
3)安装Node.js、Git yum install nodejs git -y
4)检查安装 node -v npm -v

2.安装Hexo博客框架
1)利用npm安装淘宝源
npm config set registry https://registry.npm.taobao.org
npm install -g cnpm --registry https://registry.npm.taobao.org
2)安装Hexo
npm install -g hexo-cli
3)检查安装
hexo -v

3.开始使用Hexo搭建博客
这里直接使用Hexo官网提供的命令
npm install hexo-cli -g
hexo init blog #自动部署
cd blog
npm install
hexo server #启动服务
当看到Start blogging with Hexo! 时,说明搭建成功了
这时访问localhost:4000就可以看到你生成的博客了

生成SSH添加到GitHub
git config --global user.name “你的github账户”
git config --global user.email “你的邮件”
ssh-****** -t rsa -C “youremail”
cat ~/.ssh/id_rsa.pub
centos部署hexo并上传到github
ssh -T [email protected] #提示
vim /rooot/Blog/_config.yml #编辑该文件如下
deploy:
type: git
repository: https://你的仓库地址
branch: master

#部署的命令
npm install hexo-deployer-git --save
hexo clean #清空生成的文件
hexo generate #生成静态文件
hexo deploy #部署文章
上传至github
hexo d

修改主题:
1、克隆github上的hexo主题
git clone https://github.com/theme-next/hexo-theme-next.git themes/next
2、使用主题
修改博客根目录下的 _config.yml 文件,注释掉原来的 theme 并新增一句 theme: xxxx (注意冒号后面有空格)

博客的目录结构如下:

  • node_modules #各种库的目录
  • public #是生成的网页文件目录
  • scaffolds #存储着新文章和新页面的初始设置
  • source #里面存放着文章、各类页面、图像等文件
    • _data
    • _posts
    • about
    • archives
    • categories
    • friends
    • tags
  • themes #主题

vim _config.yml
参数描述:title网站标题,subtitle网站副标题,description网站描述,author您的名字,language网站使用的语言,timezone网站时区。