- 准备环境
- 安装 Hexo
- 注册 Github
- 配置 SSH key
- 部署到 Github
- 开始写作
- 主题设置
- 个性化主题
- 添加评论功能
关于这篇写的不太全,可以看这篇
https://www.cnblogs.com/lzjloveit/p/14385971.html
环境准备
shiyanlou:project/ $ git version [18:28:15]
git version 2.7.4
shiyanlou:project/ $ node -v [18:28:24]
v12.14.1
shiyanlou:project/ $ npm -v [18:28:28]
6.13.4
shiyanlou:project/ $ npm install -g hexo-cli [18:28:31]
/usr/sbin/nodejs/bin/hexo -> /usr/sbin/nodejs/lib/node_modules/hexo-cli/bin/hexo
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.3.2 (node_modules/hexo-cli/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
+ hexo-cli@4.2.0
added 65 packages from 337 contributors in 3.564s
shiyanlou:project/ $ [18:28:54]
shiyanlou:project/ $ hexo init blog [18:28:54]
INFO Cloning hexo-starter https://github.com/hexojs/hexo-starter.git
INFO Install dependencies
(node:389) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
warning hexo-renderer-stylus > stylus > css-parse > css > urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
warning hexo-renderer-stylus > stylus > css-parse > css > source-map-resolve > urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
warning hexo-renderer-stylus > stylus > css-parse > css > source-map-resolve > resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
warning Your current version of Yarn is out of date. The latest version is "1.22.5", while you're on "1.7.0".
INFO Start blogging with Hexo!
shiyanlou:project/ $ cd blog [18:29:28]
shiyanlou:blog/ $ ls [18:29:30]
_config.landscape.yml node_modules scaffolds themes
_config.yml package.json source yarn.lock
shiyanlou:blog/ $ npm install
shiyanlou:blog/ $ hexo generate [18:30:01] 生成文件
INFO Validating config
INFO Start processing
INFO Files loaded in 235 ms
INFO Generated: archives/index.html
INFO Generated: archives/2021/index.html
INFO Generated: archives/2021/02/index.html
INFO Generated: index.html
INFO Generated: js/script.js
INFO Generated: fancybox/jquery.fancybox.min.css
INFO Generated: css/style.css
INFO Generated: 2021/02/06/hello-world/index.html
INFO Generated: css/fonts/fontawesome-webfont.woff2
INFO Generated: css/fonts/FontAwesome.otf
INFO Generated: css/fonts/fontawesome-webfont.woff
INFO Generated: fancybox/jquery.fancybox.min.js
INFO Generated: css/fonts/fontawesome-webfont.eot
INFO Generated: js/jquery-3.4.1.min.js
INFO Generated: css/fonts/fontawesome-webfont.ttf
INFO Generated: css/images/banner.jpg
INFO Generated: css/fonts/fontawesome-webfont.svg
INFO 17 files generated in 753 ms
shiyanlou:blog/ $ hexo server -p 8080 [18:30:13]
INFO Validating config
INFO Start processing
INFO Hexo is running at http://localhost:8080 . Press Ctrl+C to stop. 本地部署
hexo generate ---> hexo g # 生成页面文件
hexo server ---> hexo s # 启动服务预览
hexo server -p 8080 # 指定端口运行
hexo deploy ---> hexo d # 部署
hexo clean # 清除缓存,若是网页正常情况下可以忽略这条命令
注意: 仓库名必须是 <username>.github.io
,如果你的 github 名是 David,那么你的仓库名必须是 David.github.io
。
shiyanlou:blog/ $ ssh-keygen -t rsa -C "m18611694189@163.com" [18:33:34]
Generating public/private rsa key pair.
Enter file in which to save the key (/home/shiyanlou/.ssh/id_rsa):
Created directory '/home/shiyanlou/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/shiyanlou/.ssh/id_rsa.
Your public key has been saved in /home/shiyanlou/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:MwfPH/PtoLyM850+d6vJB1NRjpJk0Hnj7cGNTKGMxzQ m18611694189@163.com
The key's randomart image is:
+---[RSA 2048]----+
| .oE...o|
| Bo+++ |
| . . B=o++|
| + . .++o|
| S + o ...|
| + . * ..|
| . = .|
| .+.oo=o|
| .o***++|
+----[SHA256]-----+
shiyanlou:blog/ $ cat ~/.ssh/id_rsa.pub [18:34:02]
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDe3Ctbo/MTPzuBY26IcoACLLtxQsOR8OWDgNw03DzHNpIrqB4boRQWUC26+b1nNV+GHXZmHtzoIw+xjx3LBGaxsSxJBevNnYentXU8WN7/N8PfkbzK1SvY2q0cDTdPR+StDDHz+u42xPRT+oGG9l++cg+9v2iRIUl3edTe0ioo9WI4nxTOzpTMMfBVbcH4tiCkAbsD/nGS/rz6dcd3JjFr2iTRxdu0TZ7QF3nofpIo3q+qeTT6Xa7mPuFh3pxB1CdM86rq+/n4CGUcsAIabnuj76YdIobTycAQ0sUoHKXoDVU0PHcvXZi4q31142zXK1XZyZDV/CYk/Raqx9+bx5jX m18611694189@163.com
shiyanlou:blog/ $ [18:34:14]
shiyanlou:blog/ $ ssh -T git@github.com [18:34:14]
The authenticity of host 'github.com (52.74.223.119)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,52.74.223.119' (RSA) to the list of known hosts.
Hi LIZEJU! You've successfully authenticated, but GitHub does not provide shell access.
config.yml
shiyanlou:blog/ $ npm install hexo-deployer-git --save
npm WARN deprecated highlight.js@9.18.5: Support has ended for 9.x series. Upgrade to @latest
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.3.2 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
+ hexo-deployer-git@2.1.0
updated 1 package in 2.539s
14 packages are looking for funding
run `npm fund` for details
shiyanlou:blog/ $ git clone git@github.com:LIZEJU/LIZEJU.github.io-.git
正克隆到 'LIZEJU.github.io-'...
Warning: Permanently added the RSA host key for IP address '13.250.177.223' to the list of known hosts.
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
接收对象中: 100% (3/3), 完成.
检查连接... 完成。
开始写作
shiyanlou:blog/ $ hexo new "heox学习日记" [18:39:17]
INFO Validating config
INFO Created: /home/project/blog/source/_posts/heox学习日记.md
shiyanlou:blog/ $ hexo g -d [18:39:55]
INFO Validating config
INFO Start processing
INFO Files loaded in 183 ms
INFO Generated: 2021/02/06/heox学习日记/index.html
INFO Generated: archives/2021/02/index.html
INFO Generated: 2021/02/06/hello-world/index.html
INFO Generated: archives/2021/index.html
INFO Generated: archives/index.html
INFO Generated: index.html
INFO 6 files generated in 76 ms
INFO Deploying: git
INFO Setting up Git deployment...
初始化空的 Git 仓库于 /home/project/blog/.deploy_git/.git/
*** Please tell me who you are.
Run
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
to set your account's default identity.
Omit --global to set the identity only in this repository.
fatal: empty ident name (for <shiyanlou@2bc7e46ce263.(none)>) not allowed
FATAL {
err: Error: Spawn failed
at ChildProcess.<anonymous> (/home/project/blog/node_modules/hexo-deployer-git/node_modules/hexo-util/lib/spawn.js:51:21)
at ChildProcess.emit (events.js:223:5)
at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12) {
code: 128
}
} Something's wrong. Maybe you can find the solution here: %s https://hexo.io/docs/troubleshooting.html
shiyanlou:blog/ $ w [18:40:43]
w: 63 column window is too narrow
shiyanlou:blog/ $
shiyanlou:blog/ $ git config --global user.email "m18611694189@163.com"
shiyanlou:blog/ $ hexo g -d [18:43:04]INFO Validating config
INFO Start processing
INFO Files loaded in 172 ms
INFO 0 files generated in 97 ms
INFO Deploying: git
INFO Clearing .deploy_git folder...
INFO Copying files from public folder...
shiyanlou:blog/ $ hexo new "heox学习日记2" [18:45:25]INFO Validating config
INFO Created: /home/project/blog/source/_posts/heox学习日记2.md
shiyanlou:blog/ $ hexo g -d [18:45:33]INFO Validating config
INFO Start processing
INFO Files loaded in 173 ms
INFO Generated: 2021/02/06/heox学习日记2/index.html
INFO Generated: 2021/02/06/heox学习日记/index.html
INFO Generated: 2021/02/06/hello-world/index.html
INFO Generated: archives/index.html
INFO Generated: archives/2021/index.html
INFO Generated: archives/2021/02/index.html
INFO Generated: index.html
INFO 7 files generated in 38 ms
INFO Deploying: git
INFO Clearing .deploy_git folder...
INFO Copying files from public folder...
shiyanlou:LIZEJU.github.io-/ (main*) $ git add . [18:52:09]
shiyanlou:LIZEJU.github.io-/ (main*) $ git commit -m "1"
*** Please tell me who you are.
Run
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
to set your account's default identity.
Omit --global to set the identity only in this repository.
fatal: empty ident name (for <m18611694189@163.com>) not allowed
解决:
git config --global user.email "m18611694189@163.com"
42 git commit -m "1"
43 git config --global user.name "m18611694189@163.com"
44 git commit -m "1"
shiyanlou:LIZEJU.github.io-/ (main) $ git push [18:56:13]
warning: push.default 尚未设置,它的默认值在 Git 2.0 已从 'matching'
变更为 'simple'。若要不再显示本信息并保持传统习惯,进行如下设置:
git config --global push.default matching
若要不再显示本信息并从现在开始采用新的使用习惯,设置:
git config --global push.default simple
当 push.default 设置为 'matching' 后,git 将推送和远程同名的所有
本地分支。
从 Git 2.0 开始,Git 默认采用更为保守的 'simple' 模式,只推送当前
分支到远程关联的同名分支,即 'git push' 推送当前分支。
参见 'git help config' 并查找 'push.default' 以获取更多信息。
('simple' 模式由 Git 1.7.11 版本引入。如果您有时要使用老版本的 Git,
为保持兼容,请用 'current' 代替 'simple')
Username for 'https://github.com': m18611694189@163.com
Password for 'https://m18611694189@163.com@github.com':
对象计数中: 35, 完成.
Delta compression using up to 4 threads.
压缩对象中: 100% (28/28), 完成.
写入对象中: 100% (35/35), 886.36 KiB | 0 bytes/s, 完成.
Total 35 (delta 6), reused 0 (delta 0)
remote: Resolving deltas: 100% (6/6), done.
To https://github.com/LIZEJU/LIZEJU.github.io-.git
4aaa783..77746c4 main -> main
shiyanlou:LIZEJU.github.io-/ (main) $ hexo g -d [18:56:48]
INFO Validating config
INFO Start processing
INFO Files loaded in 145 ms
INFO Generated: 2021/02/06/heox学习日记/index.html
INFO Generated: archives/index.html
INFO Generated: archives/2021/index.html
INFO Generated: archives/2021/02/index.html
INFO Generated: 2021/02/06/hello-world/index.html
INFO Generated: index.html
INFO Generated: 2021/02/06/heox学习日记2/index.html
INFO 7 files generated in 77 ms
INFO Deploying: git
INFO Clearing .deploy_git folder...
INFO Copying files from public folder...
稍等一会,在浏览器访问网址:https://你的用户名.github.io 就会看到你的博客了
https://LIZEJU.github.io-
修改github仓库名
https://LIZEJU.github.io
https://lizeju.github.io/2021/02/06/heox%E5%AD%A6%E4%B9%A0%E6%97%A5%E8%AE%B0/
访问:
https://lizeju.github.io/archives/
主题设置
https://github.com/iissnan/hexo-theme-next
git clone https://github.com/iissnan/hexo-theme-next themes/next
打开 _config.yml
这个文件,找打 theme
属性,更改属性值:
theme: next
并且修改一下作者,网页标题等信息。
执行如下命令,先在环境进行测试,如果运行成功,执行命令到博客上。
hexo g
hexo s -p 8080
主题风格设置
Next 提供了四种主题,可以在主题配置文件 blog/themes/next/_config.yml
文件中进行选择,分别是 Muse
、Mist
、Pisces
、Gemini
:
添加头像图片
在七牛上上传图片,复制外链,在themes/next/_config.yml
中修改配置:
添加社交账号
在themes/next/_config.yml
中修改配置:
添加背景动画
在themes/next/_config.yml
中修改配置,这里选了canvas_next
,有四种效果,根据自己的喜好选择。