什么是 Hexo?
Hexo 是一个快速、简洁且高效的博客框架。Hexo 使用 Markdown(或其他渲染引擎)解析文章,在几秒内,即可利用靓丽的主题生成静态网页。
安装
1 | npm install hexo-cli -g |
2 | hexo init blog |
3 | cd blog |
4 | npm install |
5 | hexo server # 开启本地服务 简写 hexo s |
安装插件
1 | npm install hexo-generator-index --save #索引生成器 |
2 | npm install hexo-generator-archive --save #归档生成器 |
3 | npm install hexo-generator-category --save #分类生成器 |
4 | npm install hexo-generator-tag --save #标签生成器 |
5 | npm install hexo-deployer-git --save #hexo通过git发布(必装) |
6 | npm install hexo-generator-search --save #搜索生成器 |
配置
标签配置
1.生成 tags 文件
1 | hexo new page "tags" |
2.修改 index.md
在 source 下生成 tags 文件,找到tags文件下的index.md,更改为
1 | title: tags |
2 | date: 2019-11-30 11:03:40 |
3 | type: "tags" |
注意:如果有启用多说 或者 Disqus 评论,默认页面也会带有评论。需要关闭的话,请添加字段 comments 并将值设置为 false,如:
1 | title: tags |
2 | date: 2019-11-30 11:03:40 |
3 | type: "tags" |
4 | comments: false |
3.开启 tags
找到主题下面的配置文件 _config.yml,比如 /themes/next 文件 下的_config.yml,更改为
1 | menu: |
2 | home: / |
3 | archives: /archives |
4 | tags: /tags |
在文章内容里添加 tags: hexo, hexo 就会加到 tags 里
搜索配置
找到blog根目录下的_config.yml文件,添加
1 | external_link: |
2 | enable: true # Open external links in new tab |
3 | field: post # Apply to the whole site |
4 | search: |
5 | path: search.xml |
6 | field: post |
7 | format: html |
8 | limit: 10000 |
在\themes\next\_config.yml 文件下,开启 local_search:
1 | local_search: |
2 | enable: true |
部署配置
找到blog根目录下的_config.yml文件,找到下面的deploy:并更改为
1 | deploy: |
2 | type: git |
3 | repo: git@github.com:wang7211401/wang7211401.github.io.git #建好的仓库地址 |
4 | branch: master |
写文章
1 | hexo new "New Article" |
在 source/_posts 下生成文章
文章摘要
文章不想在主页显示全部,可以在截断处添加
1 | <!--more--> |
安装 next 主题
1 | cd blog |
2 | git clone https://github.com/theme-next/hexo-theme-next themes/next |
安装完成后,在_config.yml文件下,找到theme,修改为
1 | theme: next |
发布
1 | hexo clean |
2 | hexo generate # 生成 简写 hexo g |
3 | hexo deploy # 发布 简写 hexo d |
4 | # 两行简写 hexo d -g |