常见的hexo命令整合
npm install hexo -g #安装
npm update hexo -g #升级
hexo init #初始化
简写
hexo n "xx.md" == hexo new "xx.md"
#新建文章,如果有标题含空格一定要有引号``hexo p == hexo publish``(第一二条命令都省略了`layout`参数,具体说明下文有提及~) ``hexo s == hexo server`` #启动服务预览 ``hexo g == hexo generate`` #生成静态页面至public目录,开启服务器后只能访问localhost:4000看到更改 ``hexo d == hexo deploy`` #部署,访问博客域名看到更改
- 合并多条命令
$ hexo d -g
或$ hexo d -g
==hexo d
和hexo g
- 草稿
hexo new draft "new draft"
#新建草稿hexo publish draft "xx.md"
#把草稿变成正式文章
(如果上述命令中没有写draft,则默认使用_config.yml文件中default_layout
默认配置。) - 模板
hexo new "postName"
#新建文章hexo new page "pageName"
#新建页面hexo generate
#生成静态页面至public目录hexo server
#本地预览效果(默认端口4000,’ctrl + c’关闭server)hexo deploy
#将.deploy目录部署到GitHub
新建、修改、删除不用重新开启服务器,直接刷新便能在本地预览效果 - 调试
hexo server -debug
#开启调试模式,可以知道当前是否有解析我们所需的脚本文件等状态信息 - 更多hexo命令戳这里hexo docs
遇到的坑坑坑
- Q1. 新文章发布并部署上github之后仍然没有更新
A1. 试一下hexo clean
清除缓存 - Q2. [error:deloyer not found:git]
A2. 安装拓展npm install hexo-deployer-git --save
hexo解疑
- layout参数说明
在hexo文档中我们可以看到一些命令如hexo new [layout] <title>
、hexo publish [layout] <filename>
有一个layout参数,倘若上述命令中没有指定layout,就会默认使用_config.yml文件中default_layout
默认配置(如果我们没有修改过这个配置通常默认是post)。layout
是什么呢
layout意为布局,在hexo new
命令中是指定新建文件的模板格式。hexo默认会提供三种布局draft、page、post。而在博客所在的文件夹的根目录中有一个scaffolds文件夹,里面有draft.md、page.md、post.md三个文件,这三个文件分别是设置生成不同类型模板文件的默认格式。(比如hexo new post “test”,则新建的文件会在source文件夹中的_post文件夹中看到)
- hexo new 和 hexo publish 有什么区别
hexo new [layout] title
写hexo publish [layout] title
发布(把草稿发表为文章)
(新建、删除或修改文章后,不需要重启hexo server
,刷新一下即可预览) - hexo g 和 hexo d 有什么区别
hexo g == hexo generate
生成静态页面至public目录,开启服务器后(即hexo s
)并只能访问localhost:4000看到更改hexo d == hexo deploy
部署,可以通过访问博客域名看到更改hexo d -g
#在部署前生成- 怎么给文章分类和加标签?123456categories:- Diary- love // 此时love会成为Diary的子目录tags:- PS3- Games
- 怎么给文章分类和加标签?
- 合并多条命令
最后最后,如有错误欢迎指出~ 转载请注明本文地址