To create a new post or a new page, you can run the following command:
$ hexo new [layout] <title>
postis the defaultlayout, but you can supply your own. You can change the default layout by editing thedefault_layoutsetting in_config.yml.
Layout
There are three default layouts in Hexo:post,pageanddraft. Files created by each of them is saved to a different path. Newly created posts are saved to thesource/_postsfolder.
Layout
Path
post
source/_posts
page
source
draft
source/_drafts
Disabling layout
If you don’t want an article (post/page) to be processed with a theme, setlayout: falsein its front-matter. Refer tothis sectionfor more details.
Filename
By default, Hexo uses the post title as its filename. You can edit thenew_post_namesetting in_config.ymlto change the default filename. For example,:year-:month-:day-:title.mdwill prefix filenames with the post creation date. You can use the following placeholders:
Placeholder
Description
:title
Post title (lower case, with spaces replaced by hyphens)
:year
Created year, e.g.two thousand and fifteen
:month
Created month (leading zeros), e.g.04
:i_month
Created month (no leading zeros), e.g.four
:day
Created day (leading zeros), e.g.07
:i_day
Created day (no leading zeros), e.g.seven
Drafts
Previously, we mentioned a special layout in Hexo:draft. Posts initialized with this layout are saved to thesource/_draftsfolder. You can use thepublishcommand to move drafts to thesource/_postsfolder.publishworks in a similar way to thenewcommand.
$ hexo publish [layout] <title>
Drafts are not displayed by default. You can add the--draftoption when running Hexo or enable therender_draftssetting in_config.ymlto render drafts.
Scaffolds
When creating posts, Hexo will build files based on the corresponding file inscaffoldsfolder. For example:
$ hexo new photo"My Gallery"
When you run this command, Hexo will try to findphoto.mdin thescaffoldsfolder and build the post based on it. The following placeholders are available in scaffolds:
Placeholder
Description
layout
Layout
title
Title
date
File created date
Supported Formats
Hexo supports posts written in any format, as long as the corresponding renderer plugin is installed.
For example, Hexo hashexo-renderer-markedandhexo-renderer-ejsinstalled by default, so you can write your posts inmarkdownor inejs. If you havehexo-renderer-puginstalled, then you can even write your post in pug template language.
You can rename your posts and change the file extension from.mdto.ejs, then Hexo will usehexo-renderer-ejsto render that file, and so do the other formats.