欢迎来到我的博客

这是我用 Hexo + GitHub 搭建的第一个博客文章

【2023最新版】Hexo+github搭建个人博客并绑定个人域名_github搭建hexo博客绑定域名-CSDN博客


网页美化:

hexo博客搭建&美化教程 | 深白色的赛博产房

(20 封私信 / 33 条消息) Hexo 博客美化合集(不断更新) - 知乎


安装nodejs后进行测试显示如下错误:

1
2
3
4
5
nvm-desktop: command not found: "node"

解决:

因为是用nvm-desktop对nodejs进行管理所以与大部分的错误不同,我需要在nvm-desktop下载对应的版本以及应用才可显示对应的版本。

express出现在node_cache中:

1
对node_cache和node_global的命令处理不一样,我把他们的命令弄相同了。

Permission denied (publickey).

1
2
3
4
5
我在密钥那一步显示的是$ ssh -T git@github.com
git@github.com: Permission denied (publickey).
请问该怎么解决呢

手动把id_rsa.pub里的内容复制到github设置里的SSHkey中

文档 | Hexo此处安装hexo

1
以管理员的身份使用命令行安装

hexo init 提示不是安装命令

1
换成npx hexo init

输入npx hexo init报错

1
2
3
INFO  Cloning hexo-starter https://github.com/hexojs/hexo-starter.git fatal: unable to access 'https://github.com/hexojs/hexo-starter.git/': Recv failure: Connection was reset WARN  git clone failed. Copying data instead FATAL Something's wrong. Maybe you can find the solution here: https://hexo.io/docs/troubleshooting.html Error: EPERM: operation not permitted, mkdir 'D:\'    at async Object.mkdir (node:internal/fs/promises:860:10)

可能是因为github防火墙问题,重新再试一遍

接着报错Please run ‘npm install’ in “D:\Blog” folder.

1
2
3
4
5
6
7
8
9
INFO  Cloning hexo-starter https://github.com/hexojs/hexo-starter.git
INFO Install dependencies
WARN Failed to install dependencies. Please run 'npm install' in "D:\Blog" folder.



发现了一个大问题,居然说找不到npm命令。检查一遍没有错啊,软件安装了啊,用Windows下DOS命令npm -v ,没有发现什么问题。没办法了只有百度,得知安装完nodejs之后配置windows环境变量只能保证在命令行工具中可以使用npm,如果想在git bash中使用需要再安装一遍。

git clone --recursive git://github.com/isaacs/npm.git

接着报错 errno=Connection timed out

1
2
3
4
5
6
7
8
9
$ git clone --recursive git://[github.com/isaacs.npm.git](https://github.com/isaacs.npm.git) Cloning into 'isaacs.npm'... fatal: unable to connect to [github.com](https://github.com/): [github.com](https://github.com/)[0: 20.205.243.166]: errno=Connection timed out

克隆仓库时遇到了连接超时问题,这通常是网络连接或访问方式的问题。



GitHub 支持 `git://`、`https://`、`ssh` 三种协议,`git://` 协议可能被部分网络屏蔽,建议换成 `https://` 协议重试:

git clone --recursive https://github.com/isaacs/npm.git

接着报错Please run ‘npm install’ in “D:\Blog” folder.

1
已操作以上步骤     直接在git bash(还是之前的路径)输入npm install

启动本地服务器预览博客

1
2
在项目目录(`D:\Blog`)下执行以下命令,启动 Hexo 本地服务:
npx hexo server

unable to access ‘https://github.com/sunjing-coder/second.git/‘: Failed to connect to github.com port 443 after 21152 ms: Could not connect to server FATAL Something’s wrong.

1
2
3
4
5
6
7
8
9
网络原因


打开 `D:\Blog\_config.yml`,找到 `deploy` 配置,将 `repo` 改为 SSH 格式:

deploy:
type: git
repo: git@github.com:sunjing-coder/second.git # 注意是 SSH 格式,不是 https
branch: main # 确保分支是 main(GitHub 默认分支)

github加速访问

1
2
3
在终端以管理员的身份:

"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" --host-rules="MAP github.com octocaptcha.com, MAP github.githubassets.com yelp.com, MAP *.githubusercontent.com githubusercontent.com" --host-resolver-rules="MAP octocaptcha.com 20.27.177.113, MAP yelp.com 199.232.240.116, MAP githubusercontent.com 199.232.176.133"

hexo部署到github上但是无法显示样式

1
2
3
4
5
6
D:\Blog\_config.yml
在这个文件中:
url: https://用户名.github.io/仓库名 # 例如 https://abc.github.io/blog
root: /仓库名/ # 必须和仓库名一致,前后都带斜杠,例如 /blog/

这块得改
1
2
3
4
5
再重新部署
hexo clean # 清除旧缓存
hexo g # 重新生成静态文件(此时资源路径会自动加上 /second/ 前缀)
hexo d # 重新部署到 GitHub


撰写文章

1
2
3
4
5
6
7
npx hexo new "文章标题"

然后直接用typora打开该文档编辑即可

npx hexo cl
npx hexo g
npx hexo s # 清除缓存 → 生成静态文件 → 启动本地服务器
1
2
3
npx hexo cl 
npx hexo g
npx hexo d # 清除缓存 → 生成静态文件 → 部署到github上