环境准备
- Windows 10
- Git
- NodeJs
- Gitee 账号
- Github 账号
- 域名一个(可选)
本地搭建
在新建的hexo 目录下执行
1.cnpm 安装Hexo
1 | > cnpm install -g hexo-cli |
2.检查Hexo是否安装成功
1 | > hexo -v |
3.在hexo目录下新建目录hexo-blog,并执行命令
1 | > hexo init |
4.执行下面命令
1 | > cnpm install |
5.启动安装好的hexo
1 | > hexo s -g |
安装主题
1.挑选主题
1 | > https://hexo.io/themes/ |
2.已A-Ayer主题为例,在hexo/hexo-blog目录下执行命令:
1 | > git clone https://github.com/Siricee/hexo-theme-Chic.git themes/Chic |
4.修改配置文件_config.xml配置
1 | > theme: Chic |
5.启动hexo即可
1 | > hexo s -g |
托管Gitee
1.新建仓库hexo-blog
2.修改_config.yml文件,添加你创建的itee仓库地址
1 | deploy: |
3.发布
1 | # 安装自动部署发布工具 |
4.如有样式问题,修改_config.yml中配置
1 | url: http://isspark.gitee.io/hexo-blog/ |
托管Github
1.创建GitHub仓库,并命名xxxx.github.io,建议xxxx替换为你Github的账号名
2.配置_config.yml
1 | deploy: |
3.发布
1 | # 安装自动部署发布工具: |
4.自定义域名
- 将域名指向GitHub的服务器地址, 192.30.252.153 和 192.30.252.154
- 进入存放博客的GitHub仓库,点击settings,设置Custom domain,输入www.crazyz.cn
- 本地博客文件source中创建一个名为CNAME文件,不要后缀。写上内容你的域名
- 发布:hexo clean && hexo g && hexo d
基本操作
生成标签和分类
1 | ## 生成标签 |
对文章进行分类和添加标签
在文章文件头部添加下列:
1 |
|
新建文章
1 | ## 执行下面命令,会自动在_posts目录生成文章MD文件,编辑即可 |
错误
设置了tag和category,但是没有显示出来
1.设置/tags/index.md 和 /categories/index.md如下:
1 |
|
2.注意,在上文的layout值需要与主题文件夹下的/layout对应的tag和category 后缀ejs文件对应