Hexo Quick Start

Part I. Set Up A Website

1. Download and install

Install Node.js and Git.

Install Hexo with npm,

1
npm install -g hexo-cli

2. Init a website

1
hexo init [folder]

Initializes a website. If no folder is provided, Hexo will set up the website in the current directory.

Then, go to the website folder and init it.

1
2
cd <folder>
npm install

After that, your project folder will look like this.

1
2
3
4
5
6
7
8
.
├── _config.yml
├── package.json
├── scaffolds
├── source
| ├── _drafts
| └── _posts
└── themes

3. Files and folders

  • _config.yml: main configuration file for the website.
  • package.json: application data, including dependencies such as Markdown render and so on.
  • scaffolds/: template folder. When you create a new post, Hexo bases the new file on the scaffold.
  • source/: put source markdown files and other resources here.
  • themes/: download new themes to here.
  • publish/: after generating, the static files will be here. They’ll be deployed to remote server.

4. Deploy to GitHub

Open __config.yml file and set deploy part to this.

1
2
3
4
deploy:
type: git
repo: git@github.com:...
branch: master

Of course, you should generate your SSH key and put the put the public key on your github account.

Part II. Publish An Article

1. Create a new page

1
hexo new [layout] <title>

Creates a new article. If no layout is provided, Hexo will use the default_layout from _config.yml. If the title contains spaces, surround it with quotation marks.

2. Generate static files

1
hexo generate [-d]

-d means it will deploy after generation finishes.

3. Deploys the website

1
hexo deploy [-g]

-g means it will generate before deployment.

So if you want to generate and then deploy, you can use any of the two commands and their short format.

1
hexo g -d

or

1
hexo d -g

4. Publishes a draft

1
hexo publish [layout] <filename>

TODO: not understand what publish means.