搭建属于自己的Blog


一、创建github个人仓库

1.进入https://github.com/官网注册
2.建立仓库(注意,仓库名格式:用户名.http://github.io)

二、下载:git、nodejs

1.下载链接
(1)https://git-scm.com/download/win
(2)https://nodejs.org/zh-cn/
2.检查软件是否安装成功(
(1)检查git:git –version(新建文件夹blog,在里面空白处右击Git Bash Here,输入git –version,出现版本号就算成功了)
(2)检查nodejs:node -v(Win+R ,输入 cmd ,回车。输入 node -v ,npm -v,回车;输入 npm -v,出现版本号就算成功了)

三、安装hexo

1.F:(冒号是英文)
2.cd F:\Program Files3.\CrazyYuchi
4.hexo init blog(建立博客)
5.cd blog(进入blog)
6.hexo serve(运行博客)(出现http://localhost:4000,在浏览器中打开即可预览)
7.Ctrl+c(结束博客)

四、编辑

1.下载vscode(在里面搜索Chines变中文
2.打开文件夹,找到自己的blog文件夹
3.进入source_post里的hello-word.md进行编辑

五、主题

1.下载主题

就是直接将主题相关的文件整个放进站点的 themes 目录即可,一般主题都提供压缩包、git 等多种安装途径。我们采用下载稳定版压缩包的方式进行安装。访问 https://github.com/theme-next/hexo-theme-next/archive/refs/tags/v7.8.0.zip 下载 7.8.0 版本 NexT 主题的压缩包,将该压缩包解压到 themes 目录,并将文件夹改名为 next 即可。(然后进行美化,不会的可以扣我,下方评论)

2.具体文件

也就是 themes 文件夹中包含一个 next 文件夹,next 中包含了多个主题相关文件、文件夹。

3.启用方法

打开站点配置文件,也就是 blog 文件夹中的 _config.yml 找到 theme 字段,默认情况下应该在 100 行的位置,将原来的 theme: landscape 改为 theme: next 即可。

4.预览

启动本地服务器可以预览主题应用之后的效果。(hexo s)

六、公私钥匙

1.在blog文件夹bash:ssh
2.继续ssh-keygen -t rsa -C “931846427@qq.com“(4次回车)
或者F:\Program Files\CrazyYuchi\blog>ssh-keygen(一直回车3次)
Generating public/private rsa key pair.
Enter file in which to save the key (C:\Users\Administrator/.ssh/id_rsa):(公钥位置,公钥id_rsa.pub,私钥id_rsa)
Created directory ‘C:\Users\Administrator/.ssh’.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in C:\Users\Administrator/.ssh/id_rsa.
Your public key has been saved in C:\Users\Administrator/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:RPZBzrPkT94YtCiqLGKBvx+eC0XO2y8RWUlQMB6Qtyw ycy@WIN10-004161903
The key’s randomart image is:
+—[RSA 3072]—-+
| .o===oo |
| …=o+ . |
| .o.+. * . |
| +E =. o = . |
|. +. .S + + |
|.. . o.. . + + |
| .o o o. + . |
|..o+ +.. |
|…+B. .. |
+—-[SHA256]—–+

F:\Program Files\CrazyYuchi\blog>
3.打开github,在settings的ssh and gpg keys,新建ssh,将钥匙复制进去(.pub里面的)。
4.确定是否绑定成功:ssh -T git@github.com
有问题可以看看这个https://blog.csdn.net/YR_112233/article/details/122436258

七、发布

1.找到_config.yml进入
deploy:
type: git
repository: git@github.com:CrazyYuchi/CrazyYuchi.github.io.git(改成仓库code的ssh地址)
branch: main
2.npm install hexo-deployer-git –saver
3.openssh
hexo g
hexo d
输入账号,密码(就是下面的令牌)
4.生成令牌:在settings的developer settings里面personal access tokens,新建一个30天,全选,令牌保存下来。
5.三步走
hexo clean(清零)
hexo g(生成)
hexo d(部署)
最后,进入自己的网站即可


Author: Crazy Yuchi
Reprint policy: All articles in this blog are used except for special statements CC BY 4.0 reprint polocy. If reproduced, please indicate source Crazy Yuchi !
  TOC