杨记

碎片化学习令人焦虑,系统化学习使人进步

0%

hexo个人博客

hexo和github搭建个人博客

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
以下命令在cmd执行
若报错:'git' 不是内部或外部命令,也不是可运行的程序
改用git bash执行命令,或将git添加到环境变量,即git安装文件夹下的bin文件

(查看hexo官方文档教程https://hexo.io/zh-cn/docs/)
1、下载nodejs
(最好不要下最新的nodejs,后面可能会出错,可以查看hero官方文档看对应版本)
也可以使用 nvs(Node Version Switcher) 或 nvm(Node Version Manager) 管理nodejs
查看版本
node -v
npm -v

2、npm install -g cnpm --registry=https://registry.npm.taobao.org
-g 全局安装
从淘宝源下载
Windows若报错,
可试着修改nodejs所在文件夹的权限
属性-》安全—》编辑-》完全控制
或管理员运行cmd
输入cnpm查看

3、cnpm install -g hexo-cli
下载hexo
hexo -v 查看

4、安装git
将git添加到环境变量,即git安装文件夹下的bin文件
cmd输入 git --version

4、创建一个文件夹xxx,用来保存以后所有博客的内容
进入这个文件夹,右键,打开Git Bash Here,
执行hexo init

也不先创建文件夹,使用 hexo init 文件夹名
报错:git clone failed. Copying data instead,需要安装git

注:若安装报错,可以把这个文件夹,删了重建,再重新尝试

http://localhost:4000不能访问的话
(有可能是其他软件占用了,
或者复制cmd显示的http://localhost:4000,不要手打)
或者 hexo s -p 5000 更换端口

npm install hexo-cli -g
hexo init blog
cd blog
npm install
hexo server


初始化博客
> hexo init 文件夹名称
新建文章
> hexo new 文章名称
(或者)
> hexo n 文章名称
在线预览
> hexo server
(或者)
> hexo s

5、在GitHub上新建一个,名称:<你的 GitHub 用户名>.github.io
- 在命令行使用 cnpm install --save hexo-deployer-git

- 修改_config.yml文件,在文件末尾修改 #Deployment 部分
# Deployment
## Docs: https://hexo.io/docs/one-command-deployment
deploy:
type: git
repo: https://github.com/yanglinqi107/yanglinqi107.github.io #github 仓库链接
# example, https://github.com/hexojs/hexojs.github.io
branch: master
一键部署
> hexo deploy
(或者)
> hexo d

6、hexo配置主页
全局配置文件_config.yml中,找到Site部分,自行配置和修改,:后面要空一格
# Site
title: yang
subltitle:
description:
author:
language: zh-cn
timezone: ''


==============================================================================
报错:
-------------------------------------
(Use `node --trace-warnings ...` to show where the warning was created)
(node:4344) Warning: Accessing non-existent property 'cd' of module exports inside circular dependency
(node:4344) Warning: Accessing non-existent property 'chmod' of module exports inside circular dependency
(node:4344) Warning: Accessing non-existent property 'cp' of module exports inside circular dependency
(node:4344) Warning: Accessing non-existent property 'dirs' of module exports inside circular dependency
(node:4344) Warning: Accessing non-existent property 'pushd' of module exports inside circular dependency
(node:4344) Warning: Accessing non-existent property 'popd' of module exports inside circular dependency
(node:4344) Warning: Accessing non-existent property 'echo' of module exports inside circular dependency
(node:4344) Warning: Accessing non-existent property 'tempdir' of module exports inside circular dependency

查看 node --trace-warnings queue.js

降低node版本,可以直接使用nvm进行版本管理
博本:https://blog.csdn.net/weixin_44349707/article/details/112307824

报错:
fatal: not a git repository (or any of the parent directories): .git

没有初始化git本地管理仓库
查看 git status

创建仓库 git init

报错:
fatal: unable to access 'https://github.com/yanglinqi107/yanglinqi107.github.io/': OpenSSL SSL_read: Connection was reset, errno 10054
造成这个错误很有可能是网络不稳定,连接超时导致的,
如果再次尝试后依然报错,可以执行下面的命令。

打开Git命令页面,执行git命令脚本:修改设置,解除ssl验证
git config --global http.sslVerify "false"




===============================================================================
可以看博文:https://blog.csdn.net/jiunian_2761/article/details/97388534

可以跳到后面的主题

- 部署到gitee上

- 注册gitee

- 创建仓库
- 仓库路径:xxxxxx.gitee.com
- 公开
- Readme初始化

- 仓库页面-》克隆/下载 -》复制ssh

- 修改 _config.yml 文件

- 生成/添加 SSH 公钥
- 打开git bash窗口
- 输入 cd ~/.ssh
- 无ssh,显示 bash: cd: /c/Users/Administrator/.ssh: No such file or directory
- 有ssh,输入 ls 查看,显示 id_rsa id_rsa.pub known_hosts
- 文件夹路径为 C:\Users\yourname\.ssh
- 创建 ssh
'''
# 注意:该命令是在本地PC上执行
ssh-keygen -t rsa -C "xxxxx@xxxxx.com"
# Generating public/private rsa key pair...
'''
注意:这里的 xxxxx@xxxxx.com 只是生成的 sshkey 的名称,并不约束或要求具体命名为某个邮箱。
现网的大部分教程均讲解的使用邮箱生成,其一开始的初衷仅仅是为了便于辨识所以使用了邮箱
'''
# 注意:该命令是在本地PC上执行
cat ~/.ssh/id_rsa.pub
# ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC6eNtGpNGwstc....
'''

- 将公钥添加到Gitee
进入gitee-》设置-》SSH公钥-》将ssh-rsa xxxxxxxxx添加创建

- 验证公钥添加结果
'''
# 注意:该命令是在本地PC上执行
ssh -T git@gitee.com
'''
显示 Hi XXX! You've successfully authenticated, but Gitee.com does not provide shell access. 则证明添加成功

- 在Gitee上开通/更新 Git Pages 服务
进入仓库-》服务-》Git Pages-》勾选强制使用https

每次修改本地的 Hexo 工程目录之后,通过 hexo g命令即可将更新后的工程部署到 Gitee。
但是,这个时候你通过浏览器看到的 Hexo 博客页面并不会更新… 你需要再次执行更新Git Pages





也可以不修改,使用默认主题

- 修改主题
git clone https://github.com/litten/hexo-theme-yilia.git themes/yilia


7、配置查看所有文章
//执行命令
npm i hexo-generator-json-content --save

//在全局配置文件_config.yml进行配置,追加这一段
jsonContent:
meta: false
pages: false
posts:
title: true
date: true
path: true
text: false
raw: false
content: false
slug: false
updated: false
comments: false
link: false
permalink: false
excerpt: false
categories: false
tags: true

8、yilia菜单
# 添加归档,分类的标签
menu:
主页: /
归档: /archives/index.html
随笔: /tags/随笔/
python: /tags/python/

9、文章摘要
<!-- more --> 分隔文章

10、md能显示图片
修改hexo根目录下的_config.yml文件的以下部分,修改不是追加
post_asset_folder: true

# URL
## Set your site url here. For example, if you use GitHub Page, set url as 'https://username.github.io/project'
url: http://example.com #改成自己博客的url,不改好像也可以




---
title: 经典算法--最大存水量问题
date: 2018-02-01 17:44:18
tags:
- 算法
- 最大存水量
---






------------------------------------------------------------------------
参考博客:https://blog.csdn.net/lynnbest/article/details/79845944

欢迎关注我的其它发布渠道