Hexo博客搭建(简化版)

Hexo博客搭建(简化版)

一、环境搭建

1.1 Git

Git官网-下载界面

> git --version

1.2 Node.js

1.2.1 下载安装Node.js

Node.js官网下载界面

> node --version
1.2.2 Hexo与Node.js
Hexo versionMinimum (Node.js version)Less than (Node.js version)
6.2+12.13.0latest
6.0+12.13.018.5.0
5.0+10.13.012.0.0
4.1 - 4.28.1010.0.0
4.08.68.10.0
3.3 - 3.96.98.0.0
3.2 - 3.30.12unknown
3.0 - 3.10.10 or iojsunknown
0.0.1 - 2.80.10unknown
1.2.3 npm
> npm --version

1.4 Hexo

> npm install -g hexo
> hexo --version

1.5 hexo-deployer-git

> npm install hexo-deployer-git --save

附:官网链接:hexo-deployer-git - npm (npmjs.com)

查看npm安装的包:

> npm list -g –depth 0 

二、博客搭建

2.1 初始化

$ hexo init HexoBlog

2.2 本地部署

$ hexo s

根据提示访问:localhost:4000

2.3 创建Github仓库并设置SSH

2.3.1 设置Github仓库
  1. 创建时选择public类型仓库即可
  2. GitHub的默认分支名称有过更新,但也可以手动进入仓库“Setting”界面的“Branches”界面进行修改
2.3.2 设置SSH
  1. 配置Git

    $ git config --global user.name "你的Github用户名"
    $ git config --global user.email "你的Github邮箱"
    
  2. 生成密钥

    $ ssh-keygen -t rsa -C "你的Github邮箱"
    
  3. 查看密钥

    $ cat ~/.ssh/id_rsa.pub
    

    PS:直接将密钥在终端里面复制即可,也可以通过路径查找。

  4. 设置仓库SSH

在这里插入图片描述

  1. 验证

    $ ssh -T git@github.com
    

    当出现Are you sure you want to continue connecting (yes/no/[fingerprint])? 输入yes等待,输出Hi xxx! You've successfully authenticated...时即连接成功。

2.4 修改博客配置文件

打开blog文件夹,找到_config.yml文件,找到deploy,按照以下格式进行修改:

deploy:
  type: git
  repo: git@github.com:你的用户名/你的用户名.github.io.git
  branch: master  #这里我后面把仓库的分支名改为master了

修改前:

deploy:
  type: ''

修改后:

deploy:
  type: git
  repository: git@github.com:jingwang-7/jingwang-7.github.io.git
  branch: master

找到URL,按照以下格式进行修改:

修改前:

# 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
## Set your site url here. For example, if you use GitHub Page, set url as 'https://username.github.io/project'
url: http://jingwang-7.github.io/

2.5 远程部署

$ hexo clean && hexo g && hexo d

三、参考资料

  1. 文档 | Hexo
  2. 2022【保姆级教程】含泪搭建hexo博客 - 知乎 (zhihu.com)

四、链接

jingwang-7

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值