How to construct your blog in an hour on hexo

Summary

OS: macOS 10.14.6(Almost the same as Windows OS except for the edition of plugin units)

Blog system: hexo

Storage system: coding

Themes: NexT

It might take you 1h~2h to complete these steps.

Apply for a domain name

This web is a perfect choice for u to get a domain name: wanwang

Highly recommended to aplly a domain name end up with .xyz

Deploy your hexo

1 Before we start…

Make sure u have already installed:

node.js

Git

2 Download hexo

Type in this on your Terminal:

1
npm install -g hexo-cli

3 Initiate hexo

Setup a folder for your blog in the root folder.

1
hexo init site
1
cd site
1
npm install

4 Release your first blog

Type these in your /site folder to make up a new blog file.

1
2
3
hexo new "hello"
hexo g
hexo s

you can view your blog files in ~site/source/_posts.

Till now, you have already setup your blog successfully. And you can paste your local site to visit it.

REMEMBER: press ctrl+C to end testing mode.

5 Edit your blog

Find your blog file in ~site/source/_posts and start editing it.

Take my first blog as an example:

Don’t forget to type this on your Terminal to upload your blog file to the local site.

1
hexo s

6 Edit your personal info

Edit config.yml in /site

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# Hexo Configuration
## Docs: http://hexo.io/docs/configuration.html
## Source: https://github.com/hexojs/hexo/
# Site
title: Hexo-demo
subtitle: hexo is simple and easy to study
description: this is hexo-demo
author: pomy
language: en
timezone: Asia/Shanghai
# URL
## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
url: http://yoursite.com
root: /
permalink: :year/:month/:day/:title/
permalink_defaults:
# Directory
source_dir: source
public_dir: public
tag_dir: tags
archive_dir: archives
category_dir: categories
code_dir: downloads/code
i18n_dir: :lang
skip_render:
# Writing
new_post_name: :title.md
default_layout: post
titlecase: false # Transform title into titlecase
external_link: true # Open external links in new tab
filename_case: 0
render_drafts: false
post_asset_folder: false
relative_link: false
future: true
highlight:
enable: true
line_number: true
auto_detect: true
tab_replace:
default_category: uncategorized
category_map:
tag_map:
# Date / Time format
## Hexo uses Moment.js to parse and display date
## You can customize the date format as defined in
## http://momentjs.com/docs/#/displaying/format/
date_format: YYYY-MM-DD
time_format: HH:mm:ss
# Pagination
## Set per_page to 0 to disable pagination
per_page: 10
pagination_dir: page
# Extensions
## Plugins: http://hexo.io/plugins/
## Themes: http://hexo.io/themes/
theme: landscape
# Deployment
## Docs: http://hexo.io/docs/deployment.html
deploy:
type:

You can add your personal info here to upload them to your website.

Deploy your coding

1 Set up an account

Open coding and set up an account of you.

2 Set up a new project

Press ‘+’ in your pages to add a project for your blog storage. Please notice that: Your project name have to be the same as your user name.

Select ‘private project’ and ‘enable README file’.

3 Clone to your folders

Open your project and copy your HTTPS url

Type this on your Terminal, paste your own url into the <>.

1
git clone <https://e.coding.net/****/****.git>

Then you’ll asked to type your mail and password. (REMEMBER: it have to be your user’s mail address and password)

4 Add some plugin units

  1. Type this in /site

    1
    npm install hexo-deployer-git --save
  2. NOTICE: This step is the most critical step, and you’d better be exceptinally careful when dealing with this

    Type this in /site

    1
    ssh-keygen -t rsa -C "zhr@outlook.com"

    NOTICE: type your own mail address in the “”

    The press ENTER to skip what it requires you to type in.

    Then type in:

    1
    2
    eval "$(ssh-agent -s)"
    ssh-add ~/.ssh/id_rsa

    Back to your USER’s folder, open .ssh folder, open .pub file and copy the content in it.

    Come to Coding-Personal Settings-SSH Keys-enable ‘Permanent Available’ and paste the content into it.

5 Upload your blog

Type this in /site

1
hexo d -g

And if it went all correct, you’ll come to a INFO like this.

About the domain name

1 Set up your coding’s domain name

Open coding-Projects-sidebarDeploy-StaticWebsite-NewWebsite, and type an name as you like.

2 Analysis your domain name

Open Aliyun-DomainName, where you can check your signed domain names.

Choose one for your blog and come to the setting mode-sidebarAnalysis-AddAnalysis

Type:CNAME

DNS:@

Value:paste your domain name from coding

3 Binding you domain name

Come to coding-BindingNewDomain-Type you domain name and enable ‘CompelHTTPS’. Refresh the site until it’s successful.

IMPORTANT!!

PROBLEMS YOU POSSIBLY MEET WITH!!!

1. npm/git fatal

This is the most common type of problems. You just have to add sudo before the code to give it permission.

1
sudo npm ...

YOU HAVE TO TYPE YOUR PASSWORD WHEN USING THIS

2. hexo fatal

Possibly because of grammar confusion or call from a wrong position. You can check your edited files for mistakes.

3. DNS fatal when anlysising domain name

Aliyun is not always reliable, you can wait for a minute or change the DNS address.

4. Failed to binding domain names

Check if your domain name have already analsised yet?

Grateful to

Who have helped me a lot when constructing my blog.