Hexo 常用命令&配置说明

Hexo

简单的整理一些 heox 常用命令,并对配置文件添加了中文注释。

查看右侧目录,快速获取相关信息!


Hexo 常用命令

详细 hexo 命令,请参阅:Hexo 指令

 1# hexo初始化
 2hexo init <文件夹名> #如果 <文件夹名> 省略,则在当前目录初始化
 3
 4# 新建页面
 5hexo new page <页面名>
 6# 新建文章
 7hexo new post <文章名> # post可以省略
 8
 9# 生成静态文件
10hexo generate
11# 可简写为
12hexo g
13
14# 启动本地服务器
15hexo server
16# 可简写为
17hexo s
18
19# 清理生成的静态文件
20hexo clean
21
22# 部署静态文件
23hexo deploy
24# 可简写为
25hexo d
26
27# 生成静态文件并部署(二选一即可)
28hexo d -g
29hexo g -d

Hexo 配置文件中文注释

我顺手把hexo的配置文件_config.yml,添加了中文注释。注释信息参考于此处。

  1# Hexo Configuration
  2## Docs: https://hexo.io/docs/configuration.html
  3## Source: https://github.com/hexojs/hexo/
  4
  5###网站配置###
  6#网站标题
  7title: Hexo
  8#网站副标题
  9subtitle: ''
 10#网站描述
 11description: ''
 12#网站的关键词。使用半角逗号 , 分隔多个关键词。
 13keywords:
 14#您的名字
 15author: dingzd
 16#网站使用的语言
 17language: zh
 18#网站时区。Hexo 默认使用您电脑的时区。对于中国大陆地区可以使用 Asia/Shanghai。
 19timezone: 'Asia/Shanghai'
 20
 21###网址####
 22#网址
 23url: http://dingzd1995.github.io/
 24#网站根目录,默认"/",放在子目录"/子目录/"
 25root: /
 26#文章的永久链接格式
 27permalink: :year/:month/:day/:title/
 28#永久链接中各部分的默认值
 29permalink_defaults:
 30
 31pretty_urls:  
 32  trailing_index: true # 移除'index.html'后缀
 33  trailing_html: true # 移除'.html'后缀
 34
 35###目录###
 36#资源文件夹,这个文件夹用来存放内容。
 37source_dir: source
 38#公共文件夹,这个文件夹用于存放生成的站点文件。
 39public_dir: public
 40#标签文件夹
 41tag_dir: tags
 42#归档文件夹
 43archive_dir: archives
 44#分类文件夹
 45category_dir: categories
 46#Include code 文件夹,source_dir 下的子目录
 47code_dir: downloads/code
 48#国际化(i18n)文件夹
 49i18n_dir: :lang
 50#跳过指定文件的渲染。匹配到的文件将会被不做改动地复制到 public 目录中。您可使用 glob 表达式来匹配路径。
 51skip_render:
 52
 53###文章###
 54#新文章的文件名称
 55new_post_name: :title.md
 56#预设布局
 57default_layout: post
 58#把标题转换为 title case
 59titlecase: false
 60#在新标签中打开链接
 61external_link:
 62  enable: true # 在新标签中打开链接
 63  field: site  #对整个网站(site)生效或仅对文章(post)生效
 64  exclude: ''  #需要排除的域名。主域名和子域名如 www 需分别配置
 65#把文件名称转换为 (1) 小写或 (2) 大写
 66filename_case: 0
 67#显示草稿
 68render_drafts: false
 69#启动 Asset(资源)文件夹
 70post_asset_folder: false
 71#把链接改为与根目录的相对位址
 72relative_link: false
 73#显示未来的文章
 74future: true
 75#代码块的设置
 76highlight:
 77  enable: true #开启代码块高亮
 78  line_number: true #显示行数
 79  auto_detect: true #如果未指定语言,则启用自动检测
 80  tab_replace: '' #用 n 个空格替换 tabs;如果值为空,则不会替换 tabs
 81  wrap: true # 将代码块包装到<table>
 82  hljs: false #CSS类使用hljs-*前缀 
 83
 84# Home page setting
 85# path: Root path for your blogs index page. (default = '')
 86# per_page: Posts displayed per page. (0 = disable pagination)
 87# order_by: Posts order. (Order by date descending by default)
 88index_generator:
 89  path: ''
 90  per_page: 10
 91  order_by: -date
 92
 93###分类 & 标签###
 94#默认分类
 95default_category: uncategorized
 96#分类别名
 97category_map:
 98#标签别名
 99tag_map:
100
101# Metadata elements
102## https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta
103meta_generator: true
104
105# Date / Time format
106## Hexo uses Moment.js to parse and display date
107## You can customize the date format as defined in
108## http://momentjs.com/docs/#/displaying/format/
109date_format: YYYY-MM-DD
110time_format: HH:mm:ss
111## Use post's date for updated date unless set in front-matter
112use_date_for_updated: false
113
114###分页###
115#每页显示的文章量 (0 = 关闭分页功能)
116per_page: 10
117#分页目录
118pagination_dir: page
119
120###包括或不包括目录和文件###
121#Hexo 默认会忽略隐藏文件和文件夹(包括名称以下划线和 . 开头的文件和文件夹,Hexo 的 _posts 和 _data 等目录除外)。通过设置此字段将使 Hexo 处理他们并将它们复制到 source 目录下。
122include:
123#Hexo 会忽略这些文件和目录
124exclude:
125#忽略文件/文件夹
126ignore:
127
128## Plugins: https://hexo.io/plugins/
129## Themes: https://hexo.io/themes/
130#当前主题名称。值为false时禁用主题
131theme: diaspora #landscape
132
133
134# Deployment
135## Docs: https://hexo.io/docs/deployment.html
136#部署部分的设置
137deploy:
138  type: 'git'
139  repo: https://github.com/dingzd1995/dingzd1995.github.io.git #github仓库地址
140  branch: master # github分支
141