I love three things in the world,sun,moon,and you. sun for morning, moon for night and you forever.

0%

使用hexo新建文章并发布

创建新文章

​ 根目录命令行输入hexo new <模板> <文章名> 新建文章,其中<模板>在根目录scaffolds文件夹中,默认情况下有三个模板postdraftpage

参数 功能 路径
post 新建文章 /source/_posts/
draft 新建草稿 /source/_drafts/
page 新建页面(标签页,分类页等) /source/

​ 通常情况下使用hexo new post <title>即可,注意这里的title不是文章名,而是新建的文件名,具体文章中显示的文章标题可以在文章文件中修改。

在博客中添加图片

​ 在博客的根目录的配置文件_config.yml中,找到 post_asset_folder项,设置为true ,这样在创建文章时会自动在文章.md所在目录/source/_posts文件夹内生成一个与文章同名的文件夹。例如新建文章hexo new post example则会生成一个example.md文件与一个名为example的文件夹。

把example这个博文需要展示的图片放在example文件夹目录下;

文章内使用[% asset_img slug [title] %](将方括号][替换为花括号}{)的格式进行插入图片即可。

发布新文章

1
2
3
$ hexo clean  //清除缓存文件 (db.json) 和已生成的静态文件 (public)
$ hexo g //生成缓存和静态文件
$ hexo d //重新部署到服务器

​ 以上是简写,也可以

1
2
3
$ hexo clean    //清除缓存文件 (db.json) 和已生成的静态文件 (public)
$ hexo generate //生成静态页面
$ hexo deploy //将文章部署到Github

​ 以上就是发布新文章到github,也可以部署到本地,在浏览中访问

1
2
3
$ hexo clean
$ hexo g
$ hexo s //本地查看预览效果

浏览器打开 http://localhost:4000/ 即可查看效果,默认端口为4000

关闭评论

​ 当集成了评论系统,如 多说 或者 Disqus,所有新建的页面都将自动开启评论。若你不需要评论,请在页面的 Front-matter 里添加 comments 字段,并将值设置为 false。如下所示:

1
2
3
4
5
---
title: new title
date: 2017-2-21 21:34:29
comments: false
---
-------------本文结束 感谢您的阅读-------------