linux github+hexo搭建博客

1. 安装git nodejs

apt-get install git
https://nodejs.org/en/下好之后
教程:https://blog.csdn.net/ty_0930/article/details/71629813
因为此处在命令行中 source /etc/profile

linux github+hexo搭建博客_第1张图片若没有
linux github+hexo搭建博客_第2张图片

2. hexo搭建

教程:https://www.jianshu.com/p/bad24beeb51e
安装好node
安装hexo

asber@asber-X550VX:~$ npm install -g hexo-cli
/home/asber/Downloads/node-v12.13.0-linux-x64/bin/hexo -> /home/asber/Downloads/node-v12.13.0-linux-x64/lib/node_modules/hexo-cli/bin/hexo
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/hexo-cli/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

+ [email protected]
added 66 packages from 313 contributors in 13.425s
asber@asber-X550VX:~$ hexo --version
hexo-cli: 3.1.0
os: Linux 5.0.0-32-generic linux x64
node: 12.13.0
v8: 7.7.299.13-node.12
uv: 1.32.0
zlib: 1.2.11
brotli: 1.0.7
ares: 1.15.0
modules: 72
nghttp2: 1.39.2
napi: 5
llhttp: 1.1.4
http_parser: 2.8.0
openssl: 1.1.1d
cldr: 35.1
icu: 64.2
tz: 2019a
unicode: 12.1
asber@asber-X550VX:~$ 

然后建立一个文件夹blog,cd进去hexo init
linux github+hexo搭建博客_第3张图片npm install,安装所需组件
输入hexo g
and
输入hexo s,启动本地服务器
访问 http://localhost:4000
OK

deploy:
  type: git
  repo: [email protected]:XinquanChen/XinquanChen.github.io
asber@asber-X550VX:~$ cd ~/.ssh/
asber@asber-X550VX:~/.ssh$ ssh-keygen -t rsa -C "[email protected]"
Generating public/private rsa key pair.
Enter file in which to save the key (/home/asber/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/asber/.ssh/id_rsa.
Your public key has been saved in /home/asber/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:jL3FEE1i12OwsXqtmoMRk8TgJWrmbi1iLipEoTChrXE [email protected]
The key's randomart image is:
+---[RSA 2048]----+
|..  oo. +o=o     |
|+o o oo. +.++    |
|=.E .. .. o. .   |
|.O    ++ + .     |
|o .   .oS + .    |
| o .  .  + .     |
|o.+ .  o. .      |
|=o .  . .o       |
|=.      o.       |
+----[SHA256]-----+
asber@asber-X550VX:~/.ssh$ 

asber@asber-X550VX:~/.ssh$ ssh -T [email protected]
The authenticity of host 'github.com (13.229.188.59)' 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,13.229.188.59' (RSA) to the list of known hosts.
Hi XinquanChen! You've successfully authenticated, but GitHub does not provide shell access.
asber@asber-X550VX:~/projects/blog$ hexo d -g
INFO  Start processing
INFO  Files loaded in 114 ms
INFO  0 files generated in 53 ms
INFO  Deploying: git
INFO  Setting up Git deployment...
已初始化空的 Git 仓库于 /home/asber/projects/blog/.deploy_git/.git/
[master (根提交) c3867a9] First commit
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 placeholder
INFO  Clearing .deploy_git folder...
INFO  Copying files from public folder...
INFO  Copying files from extend dirs...
[master f2f97be] Site updated: 2019-11-08 10:04:25
 19 files changed, 2593 insertions(+)
 create mode 100644 2019/11/08/hello-world/index.html
 create mode 100644 archives/2019/11/index.html
 create mode 100644 archives/2019/index.html
 create mode 100644 archives/index.html
 create mode 100644 fonts/default-skin.b257fa.svg
 create mode 100644 fonts/iconfont.16acc2.ttf
 create mode 100644 fonts/iconfont.45d7ee.svg
 create mode 100644 fonts/iconfont.8c627f.woff
 create mode 100644 fonts/iconfont.b322fa.eot
 create mode 100644 fonts/tooltip.4004ff.svg
 create mode 100644 img/default-skin.png
 create mode 100644 img/preloader.gif
 create mode 100644 img/scrollbar_arrow.png
 create mode 100644 index.html
 create mode 100644 main.0cf68a.css
 create mode 100644 main.0cf68a.js
 create mode 100644 mobile.992cbe.js
 delete mode 100644 placeholder
 create mode 100644 slider.e37972.js
对象计数中: 32, 完成.
Delta compression using up to 4 threads.
压缩对象中: 100% (25/25), 完成.
写入对象中: 100% (32/32), 150.32 KiB | 463.00 KiB/s, 完成.
Total 32 (delta 5), reused 0 (delta 0)
remote: Resolving deltas: 100% (5/5), done.
To github.com:XinquanChen/XinquanChen.github.io
 + 950c3e4...f2f97be HEAD -> master (forced update)
分支 'master' 设置为跟踪来自 '[email protected]:XinquanChen/XinquanChen.github.io' 的远程分支 'master'。
INFO  Deploy done: git

搭建完成


3.写文章

参考:https://www.cnblogs.com/ruruozhenhao/p/8215011.html

一开始是这样
linux github+hexo搭建博客_第4张图片

3.1MARKDOWN

Markdown是一种可以使用普通文本编辑器编写的标记语言,通过简单的标记语法,它可以使普通文本内容具有一定的格式。Markdown语法简洁明了、容易掌握,而且功能比纯文本更强,因此写博客使用它,可以让用户更加专注的写文章,而不需要费尽心力的考虑样式,相对于html已经算是轻量级语言,像有道云笔记也支持Markdown写作。并且Markdown完全兼容html,也就是可以在文章里直接插入html代码。比如给博文添加音乐,就可以直接把音乐的外链html代码插入文章中。具体语法参看:Markdown 语法说明(简体中文版) 可以说十分钟就可以入门。当然,工欲善其事必先利其器,选择一个好的Markdown编辑器也是非常重要的,这里推荐MarkPad 和The Markdown Editor for Windows ,这是带有预览效果的编辑器,也可以使用本地的文本编辑器,更多的Markdown的语法与编辑器自己可以搜索了解。
好用的markdown编辑器–remarkable,ubuntu安装remarkable:
https://blog.csdn.net/qq_41376740/article/details/79216487
下载.deb文件 就好了

3.2

我们开始正式发布上线博客文章,在命令行中输入:

hexo n “博客名字”

就会发现
linux github+hexo搭建博客_第5张图片在blog根目录下的source文件夹中的_post文件夹中多了一个 博客名字.md 文件
然后就可以使用markdown编辑器编辑了
写好博文并且样式无误后,通过hexo g、hexo d 生成、部署网页。随后可以在浏览器中输入域名浏览。
有很多关于hexo搭建markdown blog中如何写markdown 的方法
添加图片、音乐等可以在:https://www.cnblogs.com/ruruozhenhao/p/8215011.html
中查看

你可能感兴趣的:(生活)