The foreword 0.

At present, there are many platforms to publish your blog, such as CSDN, Jianshu, Nuggets and so on, and these platforms have a certain amount of traffic, a good blog will soon attract a large number of page views.

The advantages of these platforms are obvious: simple, foolproof, and interactive.

But there are some uncomfortable drawbacks: platform restrictions and some ads that will delete your post for violation

And to buy a server to build a blog and a little big cost, and the cost is very high, is not conducive to small white quickly start.

So using the blog framework and Github is somewhere in between. We used the Hexo framework and anchored the blog to github Page. So we just have to concentrate on our writing.

Github, after all, is a foreign network, it is indeed a bit slow to open, and the gitee page of the domestic site code cloud has been suspended…

1. Introduction to 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.

Hexo is a Static blog framework based on Node.js. It is easy to install and use, and can easily generate static web pages hosted on GitHub and Coding. Hexo is the preferred framework for building blogs.

The official documentation is very detailed and safe to use: hexo. IO /zh-cn/docs/

This article only extracts some of the key steps

2. Steps to build a blog using Hexo

  1. Install Git
  2. Installation Node. Js
  3. Install Hexo
  4. GitHub creates a personal repository
  5. Deploy Hexo to GitHub
  6. Change the topic
  7. Setting a Personal Domain name
  8. Published articles

3. The installation

1. Install Git
  • Windows: Download and install Git.
  • Mac: Use Homebrew, MacPorts or download the installer.
  • Linux (Ubuntu, Debian) :sudo apt-get install git-core
  • Linux (Fedora, Red Hat, CentOS) :sudo yum install git-core
2. Installation Node. Js

Node.js provides an official installer for most platforms. For users in mainland China, you can go to Taobao Node.js image download.

The above two installation methods are not the focus of this tutorial. If you can’t install it, you can search the tutorial online

3. Install Hexo

Once git is installed, you can right-click git Bash here to open a command line window and type:

$ npm install -g hexo-cli
Copy the code

This is the global installation of the Hexo scaffolding, and the subsequent installation of new blogs using Hexo on this computer is unnecessary

New Folder

$ hexo init <folder>
$ cd <folder>
$ npm install
Copy the code

Will generate a lot of folders, do not understand it does not matter, know how to configure it.

  • Node_modules: depend on the package
  • Public: stores the generated page
  • Scaffolds: Some templates for generating articles
  • Source: For storing your articles
  • Themes: the theme
  • _config.yml: Configuration file for the blog

About the parameters in the file can be viewed on the official document, here is not to say.

4. Start
$ hexo clean
$ hexo g
$ hexo s
Copy the code

These three commands are very important

Type localhost:4000 into your browser to see the generated blog page

CTRL + C to turn off the service

4. Create the GitHub repository

GitHub is very handy and works in conjunction with Git, mainly for teamwork and for downloading the best code

You can search for details yourself

Start by signing up for an account and creating a repository for yourusername.github

You must use this name or GitHub Page will not recognize your file

Generate SSH to add to GitHub

This is not the focus of this tutorial. For details, you can go to the online tutorial to find out how to use Git

Git will only work if you add your computer’s SSH to your GitHub

5. Deploy Hexo on GitHub

Find the configuration file _config.yml, scroll to the end, and configure it for your repository

deploy:
  type: git
  # YourgithubName needs to be changed to your GitHub account name
  repo: https://github.com/YourgithubName/YourgithubName.github.io.git
  Here is the name of the branch to which your code is pushed
  branch: master
Copy the code

Install the deploy – git:

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

then

$ hexo clean
$ hexo generate
$ hexo deploy

$ hexo g --d   # One-click deployment
Copy the code

Hexo Clean Cleans things that were previously generated hexo generate generates static articles, which can be used as hexo G or hexo D

Once deployed, your blog will be accessible at yourname.github. IO

6. Change the theme

Go to hexo. IO /themes/ and pick your favorite themes

It is recommended to find the most star topics on GitHub. The number of stars proves that the theme is used by more people. Comparatively, the use of documents will be more complete and clear, and the experience will be better

I won’t go into details here, but I’ll update a quick configuration tutorial using the Fluid theme later

To be more…

7. Set a personal domain name

Right now your domain name is yourname.github. IO, but it doesn’t feel like enough…

HHH So, you can buy a nifty-looking domain name according to your preference

Buy a domain name to ali cloud, different suffix price is not quite the same, can choose a cheap domain name to play, see your choice cough up.

After buying the domain name, you need to conduct real name authentication, and then go to the domain console, find the domain name you bought, click Resolve, add resolution.

Choose default for parsing line, do not select outbound

Go to your repository, set Custom Domain in Settings, and enter your domain name.

Next, you create a file called CNAME in your blog file Source, using your domain name without a suffix

Then use those commands to deploy

8. Post articles

Create a new file and open the Markdown file in source/ _POST to start editing

hexo new newpapername
Copy the code

When you’re done, use those three commands to deploy

It is recommended to install vscode, which is very convenient with a command line window, and download a Markdown Preview Enhanced plug-in to view real-time renderings written by Markdown files

9. The last

The two most important commands:

$ hexo clean
$ hexo g --d
Copy the code

It is recommended that newcomers manually deploy in this way first

You can use GitHub Page’s automatic deployment feature later when you are more familiar with GitHub and other tools

To be more…