前提:
1.新建一个github仓库
2.安装配置Node.js
3.安装配置Git
注:==仓库名称要求,yourname.github.io;==
? 勾选Initialize this repository with a README;
打开Node.js官网下载对应操作系统版本及位数的node.js
安装完成后可通过以下命令验证是否已配置成功(默认安装已自动配置环境变量)
node -v
npm -v
打开Git官网下载对应操作系统版本及位数的git
安装完成后可通过一下命令验证是否配置成功(默认安装已自动配置环境变量,即选择use Git from the Windows Command Prompt)
git --version
配置git
鼠标右键打开git bash here(以下命令都是在git bash下执行)
设置git的user name和email(第一次使用)
git config --global user.name "yourname"
git config --global user.email "youremail"
配置ssh
#生成密钥,默认存储路径:C:\User\Administrator\.ssh
ssh-keygen -t rsa -C"youremail"
#添加密钥到ssh-agent
eval "$(ssh-agent -s)"
#添加生成的SSH key到ssh-agent
ssh -add ~/.ssh/id_rsa
在github上添加ssh key.
#步骤1
登录github,点击头像下的settings
#步骤2
打开左侧的SSH and GPG keys
#步骤3
点击右侧的new SSH key
#步骤4
Title 自定义
Key输入刚才生成的C:\User\Administrator\.ssh路径下的id_rsa.pub
验证ssh是否添加成功
ssh -T git@github.com
ssh-key配置失败解决方法
首先,清除所有的key-pair
ssh-add -D
rm -r ~/.ssh
删除你在github中的public-key
重新生成ssh密钥对
ssh-keygen -t rsa -C "xxx@xxx.com"
接下来正常操作
在github上添加公钥public-key:
1、首先在你的终端运行 xclip -sel c ~/.ssh/id_rsa.pub将公钥内容复制到剪切板
2、在github上添加公钥时,直接复制即可
3、保存
小试牛刀
找到一个合适的位置创建一个新的文件夹,必须是空的。实例文件夹:D:\Blog
打开cmd,进入新建的文件
d:
cd Blog
安装hexo
npm install hexo -g
验证是否安装成功
hexo -v
初始化Blog文件夹
hexo init
安装必要的组件
npm install
生成目录结构
hexo g
#或
hexo generate
开启hexo服务,预览界面
hexo s
#或
hexo server
第一次访问
访问:localhost:4000,可看到加载的页面。
打开hexo配置文件;D:\Blog\_config.yml
文件末尾处配置:
repository:打开github仓库点击Clone or download,复制里面ssh对应的仓库地址;
# Deployment
## Docs: https://hexo.io/docs/deployment.html
deploy:
type: git
repository: git@github.com:username/username.github.io.git
branch: master
原文:https://www.cnblogs.com/tassel/p/10961906.html