鉴于自己搭个人博客时遇到很多问题,以此记录
hexo+gitee博客搭建
准备工作
1、 nodejs
2、 git
3、hexo
4、gitee 注册,登录及建立仓库
一、安装 git 、nodejs 及 hexo
vode -v
npm -v
#检查nodejs是否安装好
npm install -g cnpm --registry=https://registry.npm.taobao.org
# 淘宝镜像加速器,在windows下需要自己进行环境配置
#环境位置:C:\Program Files\nodejs\node_global
#回到cmd
cnpm
cnpm -v
#查看其版本信息
cnpm install -g hexo-cli #安装hexo框架
hexo -v #查看hexo版本
在自己想要的磁盘位置建立blog文件夹
eg: D:\person_blog\blog
#在此文件夹下打开cmd(管理员身份打开)
hexo init **** # **** 任取,博客文件夹名
#进入此文件夹
cd (文件路径)
npm install
hexo s #本地模拟访问
# 复制 http://localhost:4000/ 后,浏览器打开
二、gitee 操作
1、注册码云账号
2、新建仓库(仓库名最好与用户名一致),其他都可以不填,创建,初始化
#继续blog文件夹目录下打开cmd
git config --global user.name "用户名"
git config --global user.email "所绑邮箱"
ssh-keygen -t rsa -C "所绑邮箱" #生成密钥,可以不输密码,继续enter
# C:\Users\{user}\.ssh 下的 id_rsa.pub 打开后复制, gitee——设置——SSH公钥——粘贴
#继续blog文件夹目录下打开cmd
cnpm install hexo-deployer-git --save
gitee >> 仓库 >> 服务 >> pages >> 强制使用HTTPS 启动 >> 生成链接
打开目录下的配置_config.yml
文件,在配置文件添加代码。
#配置blog目录下的_config.yml文件
#注意格式
#type:空格git
# Deployment
## Docs: https://hexo.io/docs/deployment.html
deploy:
type: git
repo: gitee仓库地址
branch: master
#继续blog文件夹目录下打开cmd
hexo clean
hexo g
hexo d
gitee仓库 >> gengxin >> 点击生成的链接,成功