• 使用hexo编写文章
  • categories的使用
  • tags的使用
  • 使用categories在菜单中添加文章分类的导航栏

编写文章

写新文章

$ hexo new 'title'  //新建文件名为title的文章

执行后会在source/_posts目录下生成 title.md文件
使用 hexo g 生成静态文件时默认会在当前日期的文件夹下新建目录title,目录下为index.html
如:

public/2016/07/04/title/index.html

如果是中文,会生成带中文的文件夹。
由于使用的云虚拟主机为linux,且要求不能使用汉字,因此在新建命名时需要使用英文名。
可在生成后的title.md文件中更改标题:

title: 测试
date: 2016-07-04 13:03:54
tags:
categories:

编辑预览

新建文件后,开启本地服务器。执行:

$ hexo s

可使用任何编辑器编辑.md文件。 (hexo使用markdown语法)
浏览器中打开http://localhost:4000
编辑文件后在浏览器中刷新就可预览

发布

文章编辑完成后生成静态文件,使用命令

$ hexo g

hexo会根据文件变动生成新的静态文件,将变化的文件(在log中有显示)使用ftp传到服务器;


如果使用github站点,可以使用命令进行发布(需要单独配置github站点):

$ hexo deploy  

categories的使用

categories为文章归类。在文章中添加categories:
单个

categories: 分类  //冒号后需有空格    

多个

  1. 使用数组
    categories: [分类1, 分类2] //冒号后需有空格
  2. 使用列表
    1
    2
    3
    categories: 
    - 测试1 //-后需有空格
    - 测试2

tags的使用

tags为文章归类。在文章中添加tags:
单个

tags: 标签  //冒号后需有空格    

多个

  1. 使用数组
    tags: [标签1, 标签2] //冒号后需有空格
  2. 使用列表
    1
    2
    3
    tags: 
    - 测试1 //-后需有空格
    - 测试2

使用categories在菜单中添加文章分类的导航栏

  1. 设置文章的categories属性(防止中文乱码问题,使用英文)

    1
    2
    3
    categories: 
    - tech
    - cate1
  2. 主题文件中配置menu:

    • 默认主题(landscape)

      1
      2
      3
      4
      menu:
      Home: /
      Archives: /archives
      tech: /categories/tech //冒号后须有空格
    • indigo 主题

      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      11
      12
      13
      menu:
      home:
      text: 主页
      url: /
      archives:
      text: 文章列表
      url: /archives
      tech:
      text: tech
      url: /categories/tech //冒号后须有空格
      cate1:
      text: cate1
      url: /categories/cate1 //冒号后须有空格

End


hexo使用

本文地址: http://gehaiqing.com/2016/07/04/hexo-use/