Note: This series of articles mainly refer to the official documentation of Hexo, as well as some of my own experiences in using Hexo. Well, without further ado, let’s begin our Hexo tour

Warm warning: the blogger is running Windows 10, other operating systems may be slightly different

The article directories

    • I. Introduction to Hexo
    • Hexo installation
      • 1. Install Git
      • 2. Install Node.js
      • 3. Download Hexo
    • Third, Hexo local site
      • 1. Local site construction
      • 2. Basic configuration
      • 3, test,
    • 4. Hexo remote deployment
      • 1. Create a Github account
      • Create a GitHub repository
      • 3. Install the plug-in
      • 4. Modify the configuration
      • 5. Configure SSH
      • 6. Publish web pages

I. Introduction to Hexo

What is Hexo? Perhaps it’s best to quote from the official documentation:

Hexo is a fast, concise, and efficient blogging framework. It uses Markdown (or some other rendering engine) to parse articles and generate static pages with beautiful themes in seconds

Hexo installation

1. Install Git

Git is an open source distributed version control system

Download from git-scm.com/download and follow the default foolproof installation

As a bonus, if you already have Git installed, you can get the latest development version of Git itself:

$ git clone https://github.com/git/git
Copy the code

When you’re done, right click on a blank area of your desktop. If the Git Bash Here option appears, the installation is successful

2. Install Node.js

Node.js is a JavaScript environment based on the Google V8 engine that supports running JavaScript on the back end

NPM is the package management tool installed with Node.js by default

Download address: nodejs.org/en, also according to the default foolproof installation

Right click on a blank area of your desktop and select Git Bash Here to go to the Bash window

Run the node -v command to view the node version. Run the NPM -v command to view the NPM version to check whether the installation is successful

$node -v v8.11.3 $NPM -v 5.6.0Copy the code

3. Download Hexo

As mentioned earlier, NPM is a package management tool, so we can download the Hexo framework through the NPM tool

The NPM install moduleName command is used to download the moduleName. The -g parameter indicates that the moduleName is installed globally

$ npm install -g hexo
Copy the code

After the installation is complete, run the hexo -v command to view the hexo version and verify that the installation is successful

$hexo -v hexo: 3.7.1 hexo- CLI: 1.1.0 OS: Windows_NT 10.0.16299 win32 x64 http_parser: 2.8.0 node: 8.11.3 V8: 6.2.414.54UV: 1.19.1zlib: 1.2.11 ares: 1.10.1-DEV modules: 57 nghttp2:1.32.0 napi: 3 openssl: 1.0.2o ICU: 60.1 Unicode: 10.0 CLDR: 32.0 TZ: 2017CCopy the code

Third, Hexo local site

1. Local site construction

Select an appropriate location to create a folder that will serve as the root directory for Hexo to store local files

Go to that folder and open the Git bash window and enter the commands hexo init and NPM install

The hexo init command initializes this folder as the hexo root directory

The NPM install command automatically installs all modules listed in the dependency list

$ hexo init INFO Cloning hexo-starter to file ...... INFO Install dependencies ...... Added 397 Packages in 34.63s INFO Start Blogging with Hexo! $ npm install ...... Audited 4704 Packages in 5.315 S found 0 DecemberCopy the code

2. Basic configuration

Open the _config.yml file in the root directory, which is a configuration file that can be opened directly with Notepad

Here are some of the more important configurations. For the complete configuration of the site, please refer to my other article – Hexo Series (II) Configuration file details

Note There must be a space between the property and the value, for example, language: zh-cn

Title Title subtitle Description Description Keywords author author name Language Language used by the Site Zh-cn timezone specifies the timezone used by the web site. By default, the timezone of the PC is usedCopy the code

3, test,

At this point, Hexo’s personal blog site is running locally

To see how this works, open Git bash and type hexo s to launch your local site

$ hexo s
INFO  Start processing
INFO  Hexo is running at http://localhost:4000/. Press Ctrl+C to stop.
Copy the code

If the following information is displayed, the local site is successfully created

Type http://localhost:4000/ in your browser’s address bar to see the results of your site running locally

4. Hexo remote deployment

As we know, GitHub is a Git-based code hosting platform and the largest open source community in the world

GitHub offers a service called GitHub Pages that allows users to customize the project front page instead of the default source list

Thus, GitHub Pages can be thought of as static web Pages written by users and hosted on GitHub

Our goal is to deploy Hexo locally built sites on Github and make them publicly accessible

1. Create a Github account

Login to GitHub website, fill in your personal information (including username, email, password, etc.) as required, then verify your email and register your GitHub account. It is very convenient and quick

Git bash: git bash: git bash: git bash: git bash: git bash

(Be sure to replace your_name and your_email with your own information.)

$ git config --global user.name your_name
$ git config --global user.email your_email
Copy the code

Create a GitHub repository

Go to the GitHub homepage, click On New Repository to create a New repository, and fill out the repository information as follows:

The Repository name is in the format of username.github. IO, where username is the github name of the Repository

In addition, it is recommended to select Initialize this repository with a README option to generate the readme.md file

Finally, click Create Repository to Create the repository

If you open Settings, you can see that your personal website has been created. The url is username.github. IO

3. Install the plug-in

Go to the root folder of the site, open git bash and type NPM install hexo-deployer-git –save to install the plug-in

$ npm install hexo-deployer-git --save
Copy the code

4. Modify the configuration

Open the _config.yml configuration file in the root folder and perform the following operations

(Make sure you replace username with your own name and leave a space between the attribute and the value)

# Deployment
## Docs: https://hexo.io/docs/deployment.html
deploy:
  type: git
  repo: https://github.com/username/username.github.io.git
  branch: master
Copy the code

5. Configure SSH

Go to the root folder of your site, open git bash, type ssh-keygen -t rsa -c “your_email” and press Enter to get the key

(Replace your_email with your own email address)

Then, locate the id_rsa.pub file according to the file address /c/Users/user/.ssh/id_rsa.pub and copy the contents in the file

$ ssh-keygen -t rsa -C "your_email" Generating public/private rsa key pair. Enter file in which to save the key (/c/Users/user/.ssh/id_rsa): <Enter> Enter passphrase (empty for no passphrase): <Enter> Enter same passphrase again: <Enter> Your identification has been saved in /c/Users/user/.ssh/id_rsa. Your public key has been saved in /c/Users/user/.ssh/id_rsa.pub. The key fingerprint is: SHA256:0Is/n+PgAf+mUEhFgTx+nVyJRZ4Pk/nqj3YOnVOAQmE email_address The key's randomart image is: +---[RSA 2048]----+ | . o+.E=o. | | +o o.. o= | | .o.. o.oO . | | .. +.. +. = . | | +.S o .| | = o o | | . * o + | | o *oo.o.. | | o+=oo+o | +----[SHA256]-----+Copy the code

Go to Github and open Settings

Select SSH and GPG keys and select New SSH Key

Add the copied content to the Key, the Title can be set by yourself, and finally click Add SSH Key

Finally, go back to the root folder of the site, open git bash, and type SSH -t [email protected] to verify the addition

$SSH -t [email protected] The authenticity of host 'github.com (13.250.177.223)' can't be established. RSA key fingerprint  is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8. Are you sure you want to continue connecting (yes/no)? <yes> The < Enter > Warning: Permanently added 'github.com, 13.250.177.223' (RSA) to the list of known hosts. Hi Forwhfang! You've successfully authenticated, but GitHub does not provide shell access.Copy the code

6. Publish web pages

Git bash, hexo g to generate static files, hexo d to deploy to Github

Github. IO, you can see the site already deployed.