Hexo博客搭建

博客搭建

Hexo安装

安装前提

如果已经安装以上两项,可以直接安装hexo

1
$ npm install -g hexo-cli

初始化Hexo

1
2
3
4
$ cd <存放博客的路径>
$ hexo init <博客名>
$ cd <博客名>
$ npm install

创建完成,目录结构如下:

1
2
3
4
5
6
7
8
.
├── _config.yml // 配置文件
├── package.json // 应用程序的信息
├── scaffolds // 模版 文件夹
├── source // 资源文件夹
| ├── _drafts
| └── _posts // 文章
└── themes // 主题

启动服务,查看效果

1
$ hexo server // 或 hexo s

浏览器访问:http://localhost:4000/

Github关联

创建仓库,命名规则 <账户名>.github.io

修改_config.yml配置文件,末尾修改为以下内容(注意:“:”后面有一个空格)

1
2
3
4
deploy:
type: git
repository: https://github.com/xxx/xxx.github.io.git // 刚才创建仓库git链接
branch: master

推送到github仓库

1
2
$ hexo g	// 生成html静态文件
$ hexo d // push到github

然后浏览器访问 https://<账户名>.github.io,即可查看博客

绑定域名

购买域名:阿里云万网腾讯云

域名解析照下图添加即可

打开博客仓库


文章作者: 落秋
文章链接: https://www.liyb.vip/2019/05/07/Hexo博客搭建/
版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 落秋
打赏
  • 微信
  • 支付宝

评论