持续创作,加速成长!这是我参与「掘金日新计划 · 6 月更文挑战」的第20天,点击查看活动详情
Hexo 博客教程
搭建工具及环境
安装需要环境和工具Node.js 和 Git 和Hexo 创建 Github等其他服务器
在Github中新建项目 项目名 为 Github 账号名.github.io ,其他选项基本默认即可,
例如:
axueli.github.io
ssh公钥
在文件夹中右键 Git base 输入 ssh 确定是否安装ssh
输入命令行
ssh-keygen -t -rsa -C "邮箱地址" 邮箱地址为Github注册邮箱
后面点击四次回车
在C:\用户\Administrator.ssh 中找到 id_rsa.pub 文件
Ctrl + a 全选 复制 电脑公钥 到 Github中的ssh密钥
在Git Base中输入命令行
ssh -T git@github.com 测试ssh是否绑定成功
本地创建Hexo工程
在 D 盘中新建 Blog 文件夹
在Blog文件夹的根目录中找到 _config.yml 文件 ,进入后下拉到底更改为下面的命令
deploy:
type: git
repository: git@github.com:axueli/axueli.github.io.git
branch: main
右键 Git Base 输入命令行
npm install -g hexo #在Blog文件夹中安装hexo
hexo init #初始化hexo(容易失败,可多试几次,或者换源)
出现 INFO Start blogging with Hexo! 为成功
hexo s #静态生成本地的hexo页面
出现 is running at http://localhost:4000/ . Press Ctrl+C to stop. 语句
右键 copy 选中 http://localhost:4000/ 到 浏览器 生成默认博客界面,Ctrl + c 会终止运行,此时4000端口的本地静态网页会无法访问
输入命令行
npm install hexo-deployer-git --save
git config --global user.email 你的邮箱 Github的邮箱
git config --global user.name 你的名字 Github的账号名
hexo d 上传文件到Github上
后面可以通过 https://Github账号名i.github.io/ 访问你的博客
例如
https://axueli.github.io/