1.安装git,Nodejs
sudo apt install git
git绑定github
git config --global user.name "Your Name"
git config --global user.email email@xxx.com
安装nodejs
sudo apt install curl
sudo apt install nodejs
# 检查是否安装成功
git --version
npm -v
nodejs -v

2.安装hexo并初始化
1.安装
sudo apt install npm
npm install hexo-cli
2.初始化
hexo init hexo # hexo为创建的本地文件夹
cd hexo
npm install
3.运行与配置
1.运行
hexo server # 创建本地服务器

运行服务器

4.将博客部署在github上
- 建立新仓库
Github仅能使用一个同名仓库的代码托管一个静态站点,仓库名必为:用户名.github.io
- 配置ssh远程连接 (之前配置完可跳过)
git config --global user.name "用户名"
git config --global user.email "邮箱地址"
ssh-keygen -t rsa -C '邮箱同上'
然后在github中添加ssh密钥 (复制id_rsa.pub的内容)
ssh -T git@github.com # 验证是否成功

- 连接
打开博客文件夹下的_config.yml文件

- 安装插件
npm install hexo-deployer-git --save
- 重新生成
hexo g
hexo d # deploy 部署到github上
- 可能出现的问题

GitHub 从 2021 年 8 月 13 日起不再支持密码认证,需要使用个人访问令牌(PAT)或 SSH 密钥
使用ssh
ssh-keygen -t ed25519 -C "your_email@example.com" # 生成
将公钥添加至github
修改_config.yml配置文件
deploy:
type: git
repo: git@github.com:QingMaxLim/QingMaxLim.github.io.git
branch: master
重新生成
hexo g
hexo d
5.主题
(跳转主题的github网站,根据README引导进行下载)
# 记得备份_config.yml
cp _config.yml _configbak.yml
vim _config.yml
# ctrl+c 退出端口
hexo g # hexo generate 用于将你的博客内容(Markdown 文件、主题、配置等)编译成静态 HTML 文件,输出到 public 文件夹中
hexo d
github有缓存,主题可能几分钟之后才能正常显示
1208

被折叠的 条评论
为什么被折叠?



