使用 hexo 和 github 搭建 个人博客

这一篇我们来讲解如何使用 hexo 和 github 搭建个人博客。

条件:

  1. 基于node
  2. npm包管理工具

下载 hexo

npm install hexo-cli -g
// 如果使用淘宝镜像的话
npm install hexo-cli -g --registry=https://registry.npm.taobao.org

在一个空目录下执行博客系统的初始化

hexo init

hexo\source_posts md文档就是博客文档
如果要写一篇博客,新建文件 xxx.md
把md文档转html文件

hexo g

在自己的服务器预览 localhost:4000

hexo s

重新生成html文件可能会有缓存

hexo clean,hexo g

如果要和github关联 推代码到github,则需要hexo-deploy-git 插件

npm install hexo-deployer-git --save

接下来需要配置文件,修改文件 _config.yml 在最下面

 type: git
  repo: git@github.com:用户名/用户名.github.io.git
  branch: master

需要在github配置仓库 名称(用户名.github.io)
把代码推到github

hexo d

配置当前仓库可以通过网络访问页面
在仓库的首页 settings—>GitHub Pages–>改选项 Source(none—master branch)
通过 用户名.github.io 访问你的博客

在这里插入图片描述
see you ~

发布了28 篇原创文章 · 获赞 38 · 访问量 3414

猜你喜欢

转载自blog.csdn.net/weixin_44691775/article/details/104446691