hexo.butterfly 安装记录

· · 个人记录

安装 git

https://git-scm.com/download/win

将 git 地址加入环境变量。

//检测
cmd> git -v //出现版本

安装 nvm

https://github.com/coreybutler/nvm-windows/releases/tag/1.1.9

//检测
cmd> nvm -v //出现版本

安装 node.js & npm

//流程
cmd> nvm install [version] //如 nvm install 12.22.1
cmd> nvm use [version] //如 nvm use 12.22.1
//检测
cmd> node -v //出现版本
cmd> npm -v //出现版本
//命令
cmd> nvm list //已安装版本
cmd> nvm version list //可安装版本
cmd> nvm install [version] //安装[version]版本
cmd> nvm version //当前版本
cmd> nvm root //nvm安装路径
cmd> nvm use [version] //转到[version]版本

配置 npm

cmd> npm config set registry https://registry.npm.taobao.org

配置 git

//流程
Bash> git config --global user.name [yourname]
Bash> git config --global user.email [youremail]
//检测
Bash> git config -l //出现上面的用户名和邮箱
//命令
Bash> git config -l //查看所有配置
Bash> git config --system --list //查看系统配置
Bash> git config --global --list //查看用户(全局)配置
Bash> git config --global user.name [yourname] //配置用户名
Bash> git config --global user.email [youremail] //配置邮箱

连接 github

//流程
Bash> ssh-keygen -t rsa -C [youremail]
//检测
//出现奇怪的图案
//流程
ssh = C/用户文件夹/.ssh/id-rsa-pub
github.Settings.SSH and GPG keys.SSH keys.New SSH key={rand(),,ssh}
//检测
Bash> ssh -T [email protected]
      yes
//出现 Hi,... 字样

安装 Hexo

//流程
Bash> npm install -g hexo-cli
//检测
Bash> hexo -v //出现版本

在安装时出现以下报错的:

npm ERR! code CERT_HAS_EXPIRED
npm ERR! errno CERT_HAS_EXPIRED
npm ERR! request to https://registry.npm.taobao.org/hexo-cli failed, reason: certificate has expired

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Administrator\AppData\Roaming\npm-cache\_logs\2024-08-08T09_23_19_300Z-debug.log

解决方案:

cmd> npm config set strict-ssl false
//再次尝试安装,若还不行:
cmd> npm cache clean --force
cmd> npm config set registry http://registry.npm.taobao.org

新建项目

选择一个路径作为项目地址(如 C:/Hexo-Blog),在这个路径下打开 cmd:

//流程
C:/Hexo-Blog> hexo init [blogname] //如 hexo init blog-demo
C:/Hexo-Blog> cd [blogname]
C:/Hexo-Blog/blog-demo> npm i
//检验
//路径 "C:/Hexo-Blog/blog-demo" 下出现很多文件

下面记程序新建的文件夹地址(如 C:/Hexo-Blog/blog-demo)为 root。

安装 butterfly 主题

Bash>root> npm i hexo-theme-butterfly

应用主题

root>_config.yml: 【修改】 theme: butterfly
Bash>root> npm install hexo-renderer-pug hexo-renderer-stylus --save

将 root\node_modules\hexo-theme-butterfly\_config.yml 复制到 root 下,并重命名为 _config.butterfly.yml。

下面记 _config.yml 的地址为 _c,_config.butterfly.yml 的地址为 _b。

安装 KaTeX

_b:
= katex:
=   enable: true
=   per_page: true/false //(false 需要在文章开头加上 "katex: true",true 会对每个文章加载 KaTeX)
=   hide_scrollbar: true

Bash>root> npm un hexo-renderer-marked --save
Bash>root> npm un hexo-renderer-kramed --save
Bash>root> npm i hexo-renderer-markdown-it --save
Bash>root> npm install katex @renbaoshuo/markdown-it-katex

_c:
+ markdown:
+   plugins:
+     - '@renbaoshuo/markdown-it-katex'

Bash>root> hexo clean

部署到 github

//流程
npm install hexo-deployer-git --save

_c:
+ deploy:
+   type: git
+   repository: [github 项目名(ssh 版)]
+   branch: main

Bash>root> hexo clean && hexo generate && hexo deploy

//检验
//出现 Deploy done: git