This is the 9th day of my participation in the August More Text Challenge

This article records the common commands of Hexo and their descriptions. You can also refer to the official documentation for related documents.

init

$ hexo init [folder]
Copy the code

New website. If folder is not set, Hexo defaults to creating the site in the current folder.

new

$ hexo new [layout] <title>
Copy the code

Create a new article. If layout is not set, default_layout in _config.yml is used by default. If the title contains Spaces, enclose them in quotation marks.

$ hexo new "post title with whitespace"
Copy the code
parameter describe
-p.--path Customize the path to a new article
-r.--replace If there is an article with the same name, replace it
-s.--slug The Slug of the article, as the filename of the new article and the URL of the post

By default, Hexo uses the title of the article to determine the path of the article file. For standalone pages, Hexo creates a directory with a title name and places an index.md file in the directory. You can override this behavior by using the –path argument:

hexo new page --path about/me "About me"
Copy the code

The above command creates a source/about/me.md file with the title “About me” in Front Matter.

Attention! Title must be specified! If you’re not getting what you want:

hexo new page --path about/me
Copy the code

The Hexo will create source/_posts/about/me.md, and the title of the Front Matter in me.md will be “page”. This is because in the command above, hexo-CLI treats Page as the title of the article and uses the default layout.

generate

$ hexo generate
Copy the code

Generate static files.

options describe
-d.--deploy Deploy the site immediately after the file is generated
-w.--watch Monitor file changes
-b.--bail Throw an exception if any unhandled exceptions occur during the build
-f.--force Forced regenerating of the file Hexo introduces a differential mechanism ifpublicDirectory exists, thenhexo gOnly the changed files are regenerated. The effect of using this parameter is similarhexo clean && hexo generate
-c.--concurrency Maximum number of files to be generated at the same time. Default is unlimited

This command can be abbreviated as

$ hexo g
Copy the code

publish

$ hexo publish [layout] <filename>
Copy the code

Publish a draft.

server

$ hexo server
Copy the code

Start the server. By default, the url is http://localhost:4000/.

options describe
-p.--port Reset the port
-s.--static Use only static files
-l.--log Start journal recording, using overwrite record format

This command can be abbreviated as

$ hexo s
Copy the code

deploy

$ hexo deploy
Copy the code

Deploy the site.

parameter describe
-g.--generate Generate static files in advance before deployment

This command can be abbreviated as:

$ hexo d
Copy the code

render

$ hexo render <file1> [file2] ...
Copy the code

Render files.

parameter describe
-o.--output Setting the Output Path

migrate

$ hexo migrate <type>
Copy the code

Migrate content from other blogging systems.

clean

$ hexo clean
Copy the code

Clears cache files (db.json) and generated static files (public).

In some cases (especially after changing themes), you may want to run this command if you find that your changes to the site are not taking effect anyway.

list

$ hexo list <type>
Copy the code

List site information.

version

$ hexo version
Copy the code

Display the Hexo version.

Common combination commands

Clear the cache and regenerate static files

hexo clean && hexo g
Copy the code

Clear the cache, regenerate static files, and deploy simultaneously

hexo clean && hexo g -d
Copy the code

options

Safe mode

$ hexo --safe
Copy the code

In safe mode, plug-ins and scripts are not loaded. When you encounter problems installing a new plug-in, you can try to re-execute it in safe mode.

Debug mode

$ hexo --debug
Copy the code

The debugging information is displayed on the terminal and recorded in debug.log. When you run into problems, you can try again in debug mode and submit debugging information to GitHub.

Concise model

$ hexo --silent
Copy the code

Example Hide terminal information.

Path of a custom configuration file

Yml $hexo server --config custom.yml --config custom.yml The custom2. Json higher priority $hexo generate -- config custom. Yml, custom2. Json, custom3. YmlCopy the code

Path to a custom configuration file. The default _config.yml is not used when this parameter is specified. You can use paths to one YAML or JSON file, or multiple paths to YAML or JSON files separated by commas (no Spaces). Such as:

Yml $hexo server --config custom.yml $hexo server --config custom.yml Custom3. Yml highest priority, followed by custom2. Json $hexo generate -- config custom. Yml, custom2. Json, custom3. YmlCopy the code

When you specify multiple configuration files, Hexo merges them into a single _multiconfig.yml sequence. If duplicate configurations are encountered, the configuration of the next file overrides the configuration of the first file. This principle applies to any number of YAML and JSON files at any depth.

According to the draft

$ hexo --draft
Copy the code

Displays draft articles in the Source / _Drafts folder.

Custom CWD

$ hexo --cwd /path/to/cwd
Copy the code

You can define the path of the Current working directory.