前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >GitHub+Hexo 搭建博客网站

GitHub+Hexo 搭建博客网站

原创
作者头像
小陈运维
发布2022-01-08 12:55:07
3230
发布2022-01-08 12:55:07
举报
文章被收录于专栏:小陈运维小陈运维

GitHub+Hexo 搭建博客网站

    Hexo是一款基于Node.js的静态博客框架,依赖少易于安装使用,可以方便的生成静态网页托管在GitHub和Heroku上,是搭建博客的首选框架。

图片
图片

配置Github

代码语言:javascript
复制
root@hello:~/cby# git config --global user.name "cby-chen"
root@hello:~/cby# git config --global user.email "cby@chenby.cn"
root@hello:~/cby# ssh-keygen -t rsa -C "cby@chenby.cn"
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /root/.ssh/id_rsa
Your public key has been saved in /root/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:57aHSNuHDLRsy/UVOQKwrUmpKOqnkEbRuRc8jNrGVpU cby@chenby.cn
The key's randomart image is:
+---[RSA 3072]----+
|       .o.       |
|  . = .E +.      |
| . + *  + ..   . |
|  = o.oo.o  . +  |
| o.*...oS..  . o |
|.oo..   *o.   .  |
|+.     + Oo+ .   |
|+  .    =.=.+    |
| oo       .o     |
+----[SHA256]-----+
root@hello:~/cby# cat /root/.ssh/
authorized_keys  id_rsa           id_rsa.pub       known_hosts      

#需要配置到github上
#https://github.com/settings/ssh/new

root@hello:~/cby# ssh git@github.com
The authenticity of host 'github.com (20.205.243.166)' can't be established.
ECDSA key fingerprint is SHA256:p2QAMXNIC1TJYWeIOttrVc98/R1BUFWu3/LiyKgUfQM.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'github.com,20.205.243.166' (ECDSA) to the list of known hosts.
PTY allocation request failed on channel 0
Hi cby-chen! You've successfully authenticated, but GitHub does not provide shell access.
Connection to github.com closed.
root@hello:~/cby#
复制代码
图片
图片

*将id_rsa.pub文件中的内容粘贴进去

安装nvm工具

代码语言:javascript
复制
root@hello:~/cby# curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
root@hello:~/cby# nvm install --lts
Installing latest LTS version.
Downloading and installing node v16.13.1...
Downloading https://nodejs.org/dist/v16.13.1/node-v16.13.1-linux-x64.tar.xz...
############################################################################################################################################### 100.0%
Computing checksum with sha256sum
Checksums matched!
Now using node v16.13.1 (npm v8.1.2)
root@hello:~/cby# nvm use --lts
Now using node v16.13.1 (npm v8.1.2)
root@hello:~/cby# 
root@hello:~/cby# node -v
v16.13.1
root@hello:~/cby#
复制代码

配置hexo环境,并修改主题

代码语言:javascript
复制
root@hello:~/cby# npm install -g hexo-cli 
root@hello:~/cby# npm install hexo -g
root@hello:~/cby# npm update hexo -g 
root@hello:~/cby# hexo init
INFO  Cloning hexo-starter https://github.com/hexojs/hexo-starter.git
INFO  Install dependencies
INFO  Start blogging with Hexo!

#修改主题
root@hello:~/cby# rm -rf scaffolds source themes _config.landscape.yml _config.yml package.json yarn.lock
root@hello:~/cby# git clone https://github.com/V-Vincen/hexo-theme-livemylife.git
root@hello:~/cby# mv hexo-theme-livemylife/* ./
root@hello:~/cby# rm -rf hexo-theme-livemylife
root@hello:~/cby# npm install
复制代码

修改配置文件

代码语言:javascript
复制
root@hello:~/cby# vim _config.yml
root@hello:~/cby# 
root@hello:~/cby# 
root@hello:~/cby# cat _config.yml
#略

# Deployment
## Docs: https://hexo.io/docs/deployment.html
##
deploy:
  type: git
  repo: https://github.com/cby-chen/cby-chen.github.io.git # or https://gitee.com/<yourAccount>/<repo>
  branch: master
root@hello:~/cby# 


root@hello:~/cby# hexo clean 
root@hello:~/cby# hexo g 
root@hello:~/cby# hexo d


#注意,输入密码是需要输入token,创建时需要勾选所有权限
#https://github.com/settings/tokens/new
复制代码
图片
图片

Linux运维交流社区

Linux运维交流社区,互联网新闻以及技术交流。

79篇原创内容

公众号

图片
图片

www.oiox.cn/

www.chenby.cn/

cby-chen.github.io/

weibo.com/u/598247412…

blog.csdn.net/qq\_3392175…

my.oschina.net/u/3981543

www.zhihu.com/people/chen…

segmentfault.com/u/hppyvyv6/…

juejin.cn/user/331578…

space.bilibili.com/352476552/a…

cloud.tencent.com/developer/c…

www.jianshu.com/u/0f894314a…

www.toutiao.com/c/user/toke…

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • GitHub+Hexo 搭建博客网站
  • 配置Github
  • 安装nvm工具
  • 配置hexo环境,并修改主题
  • 修改配置文件
相关产品与服务
云服务器
云服务器(Cloud Virtual Machine,CVM)提供安全可靠的弹性计算服务。 您可以实时扩展或缩减计算资源,适应变化的业务需求,并只需按实际使用的资源计费。使用 CVM 可以极大降低您的软硬件采购成本,简化 IT 运维工作。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档