前提:html
1.新建一个github仓库node
2.安装配置Node.jsgit
3.安装配置Gitgithub
注:==仓库名称要求,yourname.github.io;==shell
勾选Initialize this repository with a README;npm
打开Node.js官网下载对应操做系统版本及位数的node.jsbash
安装完成后可经过如下命令验证是否已配置成功(默认安装已自动配置环境变量)hexo
node -v npm -v
打开Git官网下载对应操做系统版本及位数的gitssh
安装完成后可经过一下命令验证是否配置成功(默认安装已自动配置环境变量,即选择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: 一、首先在你的终端运行 xclip -sel c ~/.ssh/id_rsa.pub将公钥内容复制到剪切板 二、在github上添加公钥时,直接复制便可 三、保存
小试牛刀
找到一个合适的位置建立一个新的文件夹,必须是空的。实例文件夹: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