个人博客效果
1、下载相关需要的软件
在下载之前,先注册一个Github账号
2、绑定github仓库
2.1 创建SSH私钥
-
打开Git Bash(在下载完Git后,点开开始页面即可看到下面的三个图标)

-
打开Git Bash后,可看到下面的界面

-
输入一下代码绑定你的Github用户以及邮箱(我之前操作过了,我就不操作了)
<span style="background-color:#f8f8f8"><span style="color:#3300aa">git</span> config <span style="color:#0000cc">--global</span> user.name <span style="color:#aa1111">"你的Github用户名"</span> <span style="color:#3300aa">git</span> config <span style="color:#0000cc">--global</span> user.email <span style="color:#aa1111">"你的邮箱"</span></span> -
然后使用一下代码创建SSH私钥
<span style="background-color:#f8f8f8">ssh-keygen <span style="color:#0000cc">-t</span> rsa <span style="color:#0000cc">-C</span> <span style="color:#aa1111">"你的邮箱"</span> <span style="color:#aa5500">## 输入自己的邮箱</span> <span style="color:#aa5500"># 然后一直按enter健即可</span></span> -
完成后可以到本地查看产生的SSH密钥
一般在C:\用户\你的用户名\.ssh
2.2 添加私钥



ERROR: 在添加私钥时,如出现Key is invalid. You must supply a key in OpenSSH public key format报错则使用id_rsa.pub内的私钥进行绑定
2.3 创建连接Github仓库
2.3.1 在.ssh文件夹中创建一个config文件

2.3.2 在config文件中输入一下内容
<span style="background-color:#f8f8f8"><span style="color:#333333">Host github.com
HostName ssh.github.com # 这是最重要的部分
User git
Port 443
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa</span></span>
2.3.3 测试来连接ssh库
<span style="background-color:#f8f8f8"><span style="color:#333333"><span style="color:#3300aa">ssh</span> <span style="color:#3300aa">git</span>@github.com
The authenticity of host <span style="color:#aa1111">'[ssh.github.com]:443 ([20.205.243.160]:443)'</span> can<span style="color:#aa1111">'t be established.</span>
ED25519 key fingerprint is SHA256:<span style="color:#981a1a">+</span>DiY3wvvV6TuJJhbpZisF/zLDA0zPMSvHdkr4UvCOqU.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? <span style="color:#3300aa">yes</span>
Warning: Permanently added <span style="color:#aa1111">'[ssh.github.com]:443'</span> (ED25519) to the list of known hosts.
PTY allocation request failed on channel <span style="color:#116644">0</span>
Hi passer24! You<span style="color:#aa1111">'ve successfully authenticated, but GitHub does not provide shell access.</span>
Connection to <span style="color:#3300aa">ssh</span>.github.com closed. //显示 HI <span style="color:#009900">`你的用户名`</span>!即为连接成功</span></span>
3、安装hexo
3.1 更改nmp镜像源
<span style="background-color:#f8f8f8"><span style="color:#333333"><span style="color:#009900">`进入cmd`</span>
<span style="color:#3300aa">npm</span> config <span style="color:#770088">set</span> registry https://registry.npmmirror.com</span></span>
注意此处的镜像源有些博客是使用的带有taobao的网址,需要使用这个新的网址,否则会出现证书的报错
3.2 创建一个文件夹 用于hexo初始化
使用nmp安装hexo
<span style="background-color:#f8f8f8"><span style="color:#333333">nmp install <span style="color:#0000cc">-g</span> hexo-cli</span></span>
3.3 初始化hexo
<span style="background-color:#f8f8f8"><span style="color:#333333">hexo init
<span style="color:#009900">` 初始化完成后会出现一下几行提示`</span>
INFO Cloning hexo-starter https://github.com/hexojs/hexo-starter.git
INFO Install dependencies
INFO Start blogging with Hexo!</span></span>
但是这一步通常需要科学上网工具,并且使用了科学上网工具也不一定能解决整个问题
这里有一个办法可以有效地解决这个问题 并且不需要科学上网工具
3.3.1 出现ERROR

-
打开Git Bash

-
进入你设置好的博客的文件夹
运行以下代码
npx hexo init myblog
注意文件必须是空的不然会报错 运行完以上代码 出现 start blogging with hexo! 就成功了
3.4 部署到github上
-
刚刚初始化玩的文件夹内容如下图所示:

-
打开_config.yml文件,找到Deployment

-
在GitHub中创建一个仓库s,复制仓房的ssh链接
命名必须是你的用户名字.github.io

-
点击code

-
复制SSH链接(结果测试,使用SSH更加稳定相比于HTTPS)

-
然后将链接放到_config.yml的Deployment下

-
在博客的文件夹下打开Git Bash,并输入
hexo g -d即可完成部署,看到如下图示,即为成功上传
-
登录自己的网站也就是(github用户名).github.io,可以发现已经更新博客内容

2125

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



