Hexo是一款快速、简洁且高效的博客框架,通过使用Markdown语法,快速创建静态页面,并能快速部署到Github或个人服务器上,且拥有大量插件以满足各种需求。
本篇主要介绍了如何安装使用Hexo,本地平台为MacOS。
安装依赖以及Hexo
1. 安装nvm和node.js
1 2 3
| brew install nvm
nvm install lts
|
最新更新:当前使用node版本为v22.14.0
2. 安装git
3. 安装hexo
使用Hexo
1. 初始化hexo的工作目录
1 2 3 4 5 6
| cd ~ hexo init <folder> cd <folder>
npm install
|
2. 修改配置信息_config.yml
,可以设置作者、网站名字等
1 2 3 4
| title: My Blog author: LePhee language: zh-CN url: http://www.lephee.net
|
3. 安装皮肤icarus
1 2
| npm install hexo-theme-icarus hexo config theme icarus
|
修改_config.icarus.yml
配置文件
1 2 3 4 5 6 7 8 9 10 11 12
| logo: logo.png
navbar: menu: 首页: '/' 归档: '/archives' 分类: '/categories' 标签: '/tags' 关于: '/about'
|
配置disqus评论
1 2 3
| comment: type: disqus shortname: 'yourshortname'
|
配置sharejs分享插件
4. 新建文章
之后会在source/_posts/
目录下创建名为MyPost.md
的markdown
文件,用该文件来写文章即可
5. 生成静态页面
6. 启动服务器
7. 打包部署
安装hexo的rsync部署工具
1
| npm install hexo-deployer-rsync --save
|
配置rsync信息,需要有rsync权限用户
1 2 3 4 5 6 7 8 9
| deploy: type: rsync host: ip user: rsyncuser root: /path/to/rsync/html port: 1111 delete: true verbose: true ignore_errors: false
|