Hexo-Github-Vercel零成本搭建博客
Hexo
准备环境
node.js
git
安装hexo
安装命令:
npm install hexo-cli -g |
Hexo指令大全:指令 | Hexo
安装完成后,使用cd
命令进入博客文件夹(没有的话自己新建)
接着使用init
博客初始化
hexo init |
接着修改文件_config.yml
文件,配置网站相关内容
使用Butterfly主题
Butterfly主题官网:Butterfly - A Simple and Card UI Design theme for Hexo
- 安装主题
git clone -b master https://gitee.com/immyw/hexo-theme-butterfly.git themes/butterfly
- 使用主题
在_config.yml
文件下把主题改成theme: butterfly
- 安装必要依赖
npm install hexo-renderer-pug hexo-renderer-stylus --save
- 将
\themes\butterfly
下的文件_config.yml
更名为_config.butterfly.yml
并复制到博客根目录
剩下的去官方文档摸索吧,官方文档:Butterfly 安裝文檔(一) 快速開始 | Butterfly
Vercel以及部署
Github部署
- 设置user.name和user.email配置信息
git config --global user.name "你的GitHub用户名"
git config --global user.email "你的GitHub注册邮箱" - 生成ssh密钥文件:
ssh-keygen -t rsa -C "你的GitHub注册邮箱"
``` 然后一直点回车就行,出现`Overwrite (y/n)? `输入`y`然后一直回车
1. 找到密钥文件
打开文件夹`C:\Users\用户名\.ssh`内的文件`id_rsa.pub`,用记事本打开即可,复制里面的内容
1. Github添加SSH
[SSH and GPG keys (github.com)](https://github.com/settings/keys) 打开网址,点击New SSH Key,title随意写,Key填写刚刚复制的内容
1. 检查Github公钥是否设置成功
```shell
ssh git@github.com
``` ![image.png](https://jsd1.imbai.cn/gh/3401797899/blogcdn/pics/fffcb4253a4519b31e7c15d9583757c9.png) 出现这一串即连接成功
1. 在Github上新建一个仓库`用户名.github.io`
1. 修改Hexo配置文件
```yaml
deploy:
type: git
repo: git@github.com:用户名/仓库名.git
branch: master - 安装Hexo的Git部署插件
npm install hexo-deployer-git --save
- 运行Hexo三件套,进行部署
hexo clean hexo g hexo d ``` 接着你就能打开`用户名.github.io`访问你的博客了
Vercel加速
打开vercel官网:Develop. Preview. Ship. For the best frontend teams – Vercel,使用Github账号登陆
授权完成后,点击
Create a New Object
找到博客项目,点击import,然后一直下一步
进入DashBoard
如图修改,可以获得一个xxxx.vercel.app域名。(如今vercel.app已经被墙,需要使用自己的域名了 2024.4.2)
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 白!
评论