安装Hexo
参考Hexo官网文档说明进行安装
创建博客
安装喜欢的Theme
- guan6/hexo-modernist 个人比较喜欢这个
- yelee
- 安装,在博客根目录下执行:
1 2 3
| $ git clone https://github.com/guan6/hexo-modernist.git themes/modernist or $ git clone https://github.com/MOxFIVE/hexo-theme-yelee.git themes/yelee
|
配置博客
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| # Site title: <网站标题> subtitle: <副标题> description: <描述> author: <作者> language: zh-Hans timezone: # theme配置 theme: modernist # Deployment ## Docs: https://hexo.io/docs/deployment.html deploy: type: git repo: <你的github仓库,注意是:username.github.io的那一个> #其他配置根据需要进行修改 ...
|
启动博客服务
1 2
| # 注意:端口可以不指定,默认为4000 $ hexo clean && hexo -s -p 90
|
访问http://localhost:90预览博客吧…
创建博客文章
1 2 3 4
| # 创建普通博客文章,显示在首页列表中 $ hexo new [layout] <文章名称,有空格需要使用引号> # 创建一个页面,不显示在列表中,可以使用菜单及进行链接 $ hexo new page <文章名称>
|
发布博客
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| # 安装RSS插件 $ npm install hexo-generator-feed --save # 配置 feed: type: atom path: atom.xml limit: 20 hub: # 安装git发布插件(如果已安装,可忽略,具体支持的发布方式可参考hexo官网文档) $ npm install hexo-deployer-git --save # hexo g === hexo generate # hexo d === hexo deploy $ hexo clean && hexo g && hexo d
|
其他技巧
使用skip_render跳过不需要渲染的文件
- skip_render指定的位置是相对于source_dir的位置,一般来说是source目录
- skip_render使用了minimatch
- 单个文件夹下全部文件:
skip_render: test/*
- 单个文件夹下指定类型文件:
skip_render: test/*.html
- 单个文件夹下全部文件以及子目录:
skip_render: text/**
- 多个文件夹以及各种复杂情况:
1 2 3
| skip_render: - test1/*.html - test2/**
|
觉得不错的主题
参考文献
- github + hexo 构建免费博客/网站
- hexo你的博客
- Hexo博客优化
- 手把手教你使用Hexo + Github Pages搭建个人独立博客
- 如何利用GitHub Pages和Hexo快速搭建个人博客
- 如何不处理source目录下某个子目录的所有文件,仅仅是将其copy到public目录中对应目录?
- 关于 Hexo 的若干问题