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查看效果