preface

There are two requirements for building a blog: blog framework + hosting platform. Here we use Hexo as the framework, while most people choose GitHub as the platform. Here I choose Gitee, which belongs to the domestic code hosting platform. Compared with GitHub, the access speed is faster and more stable.

Environmental requirements

  • Git
  • Nodejs

The above two conditions are required to install Hexo and submit the code for hosting. The installation method can be found on your own

Blog set up

Install Hexo

Open the shell terminal and enter the command 'NPM install -g hexo'Copy the code
$ sudo cnpm install -g hexo
Password:
Downloading hexo to /usr/local/lib/node_modules/hexo_tmp
Copying /usr/local/ lib/node_modules/hexo_tmp / _hexo @ 3.7.1 @ hexo to/usr /local/lib/node_modules/hexo
.
.
.
.
Copy the code

Note: If there is a permission error, add sudo before the command, CNPM is taobao open source mirror, domestic access faster than NPM.

Initialize Hexo

Create the Hexo folder on your computer, switch to the Hexo directory in the shell terminal, and type the command Hexo init

$ cd /work/Hexo 
/work/Hexo $ hexo init
INFO  Cloning hexo-starter to /work/Hexo
Cloning into '/work/Hexo'. remote: Counting objects: 65, done. remote: Total 65 (delta 0), reused 0 (delta 0), pack-reused 65 Unpacking objects: 100% (65/65), done. Submodule'themes/landscape' (https://github.com/hexojs/hexo-theme-landscape.git) registered for path 'themes/landscape'
Cloning into '/work/Hexo/themes/landscape'. ^Cwarning: Clone succeeded, but checkout failed. You can inspect what was checked out with'git status'
and retry the checkout with 'git checkout -f HEAD'

INFO  See you again
Copy the code

After initialization, generate folders under the Hexo directory

Get the blog theme

Type the command in the shell: git clone https://github.com/iissan/hexo-theme-next themes – the next

/work/Hexo $ git clone https://github.com/iissan/hexo-theme-next themes-next
Cloning into 'themes/even'. remote: Counting objects: 136, done. remote: Compressing objects: 100% (123/123), done. remote: Total 136 (delta 4), reused 128 (delta 2) Receiving objects: 100% (136/136) and 264.27 KiB | 556.00 KiB/s, done. Resolving deltas: 100% (4/4), done.Copy the code

After cloning, under the /Hexo/ Themes directory, you can see landscape and even folders. All the themes we will use are in this directory. Hexo uses landscape theme by default, and NexT uses more and more diverse themes. We cloned the NexT theme in this step and will use the NexT theme for the demonstration. For more topics, choose your favorite topic at https://hexo.io/themes/ and clone it.

_config.yml Performs basic configuration for the blog

_config.yml can be called the site configuration file, you can configure the name, address and other basic information of the blog

Open the site configuration file to find the corresponding configuration

# Site
# Blog nameTitle: Miscellaneous non-language# subtitleSubtitle: Become a badass ordinary person# Personal ProfileDescription:# blogger
author: Sun XY
# language
language: zh-Hans
# time zone
timezone: Asia/Shanghai
# Theme skin
theme: next
Copy the code

Run locally

Compile command: hexo g

Start command: hexo s

$ hexo g
INFO  Start processing
INFO  Files loaded in 186 ms
INFO  Generated: archives/2018/08/index.html
INFO  Generated: archives/index.html
INFO  Generated: archives/2018/index.html
INFO  Generated: index.html
INFO  Generated: 2018/08/08/hello-world/index.html
INFO  5 files generated in 242 ms
$ hexo s
INFO  Start processing
INFO  Hexo is running at http://localhost:4000/. Press Ctrl+C to stop.
Copy the code

Visit http://localhost:4000/ to see the blog effect

More information about Hexo Settings can be found at hexo. IO /zh-cn/docs/

Blog deployment

Create a Gitee account

Visit https://gitee.com/ to apply for an account. The code cloud is similar to GitHub in China.

Create a project

Fill in the project name, then create the project, and when you’re done, copy the project address in the project.

Configure Git in _config.yml

# URL
## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
url: 'Fill in your own project address here'
root: 'Put the project name here.'
permalink: :year/:month/:day/:title/
permalink_defaults:
Copy the code

Note: The colon must be followed by a space, otherwise it will not be correctly identified.

Publish the project

Install the automatic deployment publishing tool: NPM install hexo-deployer-git –save

Issue the command: hexo clean && hexo g && hexo D

For the first release, you need to enter your account and password in the shell.

Gitee Pages set

Select the Pages option from the project’s services

Wait for a while and the blog will be published successfully, visit the blog address: https://sun_xy.gitee.io/blog/, you can ask the online blog!! If the style of the blog is not correct, you need to configure the blog address and path in _config.yml:

url: https://sun_xy.gitee.io/blog/
root: /blog
Copy the code

After the modification is complete, run the hexo clean && hexo g && hexo d command to update the Gitee and publish it again.

So far, the personal blog is completed!!

You can place your posts directly into the /Hexo/source/_posts directory, which supports markdown syntax.

A cliche

  • Personal blog: Xyua.Top