hexo+github如何搭建博客

1、前期准备

安装git

安装成功

D:\BlogHere>git --version
git version 2.24.1.windows.2

安装node

安装成功

D:\BlogHere>node -v
v10.18.0

D:\BlogHere>npm -v
6.14.2

全局安装hexo

npm install -g hexo

安装成功

D:\>hexo -v
hexo-cli: 3.1.0
os: Windows_NT 10.0.17763 win32 x64
http_parser: 2.8.0
node: 10.18.0
v8: 6.8.275.32-node.54
....

2、创建博客项目

(1)新建文件夹blogContain用于存放博客

D:\>mkdir blogContain

D:\>cd blogContain

D:\blogContain>hexo init

init结束正确信息为

added 373 packages from 475 contributors and audited 2629 packages in 41.059s

5 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

INFO  Start blogging with Hexo!

完成后项目中已经包含了一篇hello world的博客

(2)本地启动后访问

启动

D:\blogContain>hexo generate
...
INFO  Generated: 2020/03/17/hello-world/index.html
INFO  Generated: css/fonts/fontawesome-webfont.ttf
INFO  Generated: fancybox/jquery.fancybox.js
INFO  28 files generated in 444 ms
D:\blogContain>hexo server
INFO  Start processing
INFO  Hexo is running at http://localhost:4000 . Press Ctrl+C to stop.

访问
访问成功

3、部署到GitHub上

新建名"用户名.github.io"仓库(固定)

我的用户名为Feng404
新仓库

添加hexo-deployer-git

D:\blogContain>npm install hexo-deployer-git --save
/ [0/1] Installing picomatch@^2.0.4platform unsupported hexo-deployer-git@2.1.0 › hexo-fs@2.0.0 › chokidar@3.3.1 › fsevents@~2.1.2 Package require os(darwin) not compatible with your platform(win32)
- [0/1] Installing fill-range@^7.0.1[fsevents@~2.1.2] optional install error: Package require os(darwin) not compatible with your platform(win32)
√ Installed 1 packages
√ Linked 78 latest versions
√ Run 0 scripts
√ All packages installed (80 packages installed from npm registry, used 5s(network 5s), speed 36.36kB/s, json 79(190.37kB), tarball 0B)

修改_config.yml配置文件内容

# Deployment
## Docs: https://hexo.io/docs/deployment.html
deploy:
  type: git
  repo: https://github.com/Feng404/Feng404.github.io.git
  branch: master

执行命令部署

D:\blogContain>hexo clean
D:\blogContain>hexo generate
D:\blogContain>hexo deploy

地址栏注入Feng404.github.io查看效果

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值