What is a Hexo

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

This tutorial is run on a Mac

Prepare to set up the environment

  • Installation Node. Js

    Go to node.js

Select the installation package suitable for your current computer system. After installation, you can use the command line to check whether the installation is successful. If the version number is displayed, it means that the installation is successful.

The installationGit

It is similar to installing Node.js. Use the command line tool to check whether the installation is successful.

Create a GitHub account

GitHub is a hosting platform for open source and proprietary software projects

After registering, you need to create a repository in GitHub

Configure SSH on GitHub

Once you have registered your GitHub account, you can configure the SSH key

The first step:

On a Mac, check whether the. SSH directory exists. If yes, check whether the id_RAR and id_rsa.pub files exist in the directory. If no, run commands on the CLI to create an SSH Key

ssh-keygen -t rsa -C "[email protected]"
Copy the code

You’ll need to change your email address to the one you signed up for GitHub, press Enter, and use the default Settings.

Pub is the public Key of the SSH Key. Id_rsa is the private Key that cannot be disclosed, and id_rsa.pub is the public Key

The second step:

On the GitHub user page, select Settings.

Select SSH And GPG Keys -> New SSH Key on the left

Step 3:

Open the CLI and run commands to check whether the configuration is successful

ssh -T [email protected]
Copy the code

Are you sure you want to continue connecting(yes/no)? Type yes and see:

Hi {you name}! You've successfully authenticated, but GitHub does not provide shell access. 
Copy the code

If you see this message, SSH has been configured successfully.

$git config --global user.name "you name" $git config --global user.email "you github email"// Enter your github registered email addressCopy the code

Start a blog

Initialize the

Create a new folder in your computer directory

Mkdir hexo NPM install hexo -g hexo init then enter hexo g # to generate local file hexo s # to start the serviceCopy the code

Hexo s is to enable the local preview service, open the browser and visit http://localhost:4000/ to see the content. If you open the browser and keep going in circles, you will not be able to load the content, usually due to port usage.

The first time we initialized it hexo had already written a Hello World article for us, and when we opened it it looked like this

Upload the code to GitHub

If your blog and SSH are configured, you can publish to GitHub, just command into the currently initialized folder

Enter the command.

There is one more configuration to know. In the initializer blog folder, go to the _config.yml file and modify the configuration:

deploy:
  type: git
  repo: https://github.com/zouzhigang/zouzhigang.github.io
  branch: master

Copy the code

After configuration, you also need to install a plug-in:

deploy:
  type: git
  repo: https://github.com/zouzhigang/zouzhigang.github.io
  branch: master

Copy the code

In the file currently initializing the blog, open the command line and type hexo D to commit all the code that has been changed.

The setup is complete.

How to create a new blog

In the root directory of the Hexo blog, execute the following code from the command line:

Hexo New Post 'Post name of your blog'Copy the code

Hexo will automatically generate a file ending in MD at /source/_posts/. This is the file in Markdown format. Then you can start writing your blog.

Hexo common commands:

"# hexo new" = hexo g # hexo generate: generate; Hexo s # hexo serve: Hexo d # hexo Hexo g -d # : hexo generate; Hexo generate --deployCopy the code

Supplement:

Markdown format compiler recommendation tool: Typora official address: www.typora.io/ recommendation reason: as a free editor, can be said to be quite conscience, I know the best use of the free editor, no one!! It supports many major operating systems and is easy to install and use whether you are a Windows or Mac user. In addition, it has a variety of topics to choose from, export some common formats (PDF, Word, HTML) and very useful features!

Writing Markdown tables can be a pain for obsessive-compulsive disorder (OCD), and I really struggle with grammatical alignment, so I highly recommend an online Markdown table generator that can quickly generate formatted Markdown tables. Also support to import a variety of data, online editing, it is powerful!

Table Convert Online tableconvert.com/ As a free online tool, support Excel, JSON, HTML, CSV and even extract HTML form from URL to Markdown form, multi-functional integration, and integration in one interface, very convenient to use, there is no need to switch pages. You can also edit all kinds of tables like editing Excel, worthy of the Swiss Army knife in the table!

For those of us who write technical articles, drawing flow charts and architecture diagrams is the best way to help describe the content of articles, and ProcessOn is the tool I use most.

This is a rare online photo editor that supports multi-user collaboration. At the same time, there is a lot of beautiful icon support to make our drawing more lively!

Image storage One might ask, why image storage? Can’t we just save it in WordPress or Hexo? In fact, the use of these is mainly for economic considerations, with the increase of traffic, images for our virtual host or ECS space and bandwidth consumption will cause a certain pressure, using a platform like graph bed can help us reduce these pressures.

Recommended tool: external chain factory official address: www.wailian.work/ recommended reason: simple and easy to use, stable enough, release their virtual space or virtual host storage and bandwidth consumption, but remember to do a good backup oh!

Code highlighting is a must if you’re a programmer like me. Most Hexo themes include highlighting plugins, but some don’t, so we need to know about hightlight.js. For some of the themes that already have this plug-in, you can also make some customization through the official website, without direct introduction to use.

Suitable for all major programming languages, good compatibility, a variety of preset styles, there is always a suitable one for you!