用hexo搭建博客的尝试

github准备

Node.js 安装

hexo安装

hexo命令

1
$ hexo clean &&hexo g && hexo s
1
$ hexo d
命令 简写 中文含义
hexo server hexo s 本地启动
hexo generate hexo g 生成静态文件
hexo deploy hexo d 部署网站
hexo clean 清除缓存和已经生成的静态文件

遇见 git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

可以检查ssh 密钥

1.检查 SSH 密钥是否存在

1
ls -al ~/.ssh

检查是否有 id_rsaid_rsa.pub 文件(或其他类似名称的文件)。如果没有,你需要生成一个新的 SSH 密钥。

2.生成新的 SSH 密钥(如果需要)

1
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
  • 按 Enter 使用默认文件路径(~/.ssh/id_rsa)。
  • 设置一个密码(可选,但建议设置以增强安全性)。

3. 将 SSH 密钥添加到 SSH 代理

1
2
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_rsa

如果你使用了不同的密钥文件名,请将 id_rsa 替换为正确的文件名。

4. 将 SSH 公钥添加到 GitHub 账户

1
cat ~/.ssh/id_rsa.pub

登录 GitHub:

  1. 进入 Settings > SSH and GPG keys
  2. 点击 New SSH key
  3. 在 "Key" 字段中粘贴你的公钥,并为其命名。
  4. 点击 Add SSH key

5. 测试 SSH 连接

测试与 GitHub 的连接:

1
ssh -T git@github.com

如果成功,你会看到以下消息:

Hi <username>! You've successfully authenticated, but GitHub does not provide shell access.

使用buttfly主题

写博客

hexo new [layout] <title>

比如 hexo new "时间序列比赛(一)"

npm查看已安装的包(全局、和本地)

查看全局已安装(-g 的意思是 global 全局的意思)
npm ls -g
加上层级控制显示深度:--depth 0
npm ls -g --depth 0
查看项目中已安装
npm ls
如果只想显示生产环境依赖的包
npm ls --depth 0 --prod
只显示开发环境依赖的包
npm ls --depth 0 --dev

Hexo 多种Markdown渲染器对比分析

https://zsyyblog.com/b73ceb85.html

图床

下载并安装 PicGo,一个图像上传工具

PicGo中配置 GitHub 仓库。

Github 创建一个 token:进入 Github 主页,右上角点击头像选择 Settings -> Developer settings -> Personal access tokens,最后点击 generate new token

Github 填写基础信息,最后复制生成的 token 并保存(要记得勾选repo)

把token复制到PicGO

自定义域名可以使用 jsDelivr 为图片访问进行免费加速:https://cdn.jsdelivr.net/gh/用户名/仓库名