A few days to build their own personal blog, rent-free server, free to buy domain name, really sweet warning.

Just spent a few days to build a website, the first link, welcome to visit: dye ink small white blog

Now there are many blogs on the market, such as CSDN, Blog Garden, Jianshu and other platforms, which can be directly published on the platform. If the user interaction is good, the articles written can also be searched by Baidu. Disadvantages are less freedom, will be subject to various restrictions of the platform and disgusting advertising.

And their own domain name and server, the cost of building a blog is too high, not only to say that these purchase costs, only to take the effort to build such a website, but also the regular maintenance of it, for most of us, it is no such energy and time.

The third option is to host our blog directly on github Page. It’s safe to write without the need for regular maintenance, and hexo is a fast and concise blogging framework that makes building a blog really easy.

Hexo profile

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. You can visit Hexo’s official website for more details, because the creator of Hexo is Taiwanese and friendly to Chinese, you can choose Chinese for viewing.

This tutorial is divided into three parts,

Part 1: Hexo’s initial setup also includes deployment to Github Page and binding of personal domain names. Part 3: Hexo adds various functions, including SEO for search, read statistics, traffic statistics and comment system, etc.


The first part

Initial implementation of Hexo also includes deployment to Github pages and binding of personal domain names.

Hexo setup steps

Install Git install Node.js Install Hexo GitHub create personal repository generate SSH add to GitHub Hexo deploy to GitHub set personal domain to publish articles

1. Install Git

Git is the most advanced distributed version control system in the world, which can effectively and quickly handle project version management from small to very large. The tool used to manage your Hexo blog posts and upload them to GitHub. Git is very powerful, and I think it’s recommended that everyone check it out. Teacher Liao Xuefeng’s Git tutorial is very good, you can know about it. Git tutorial

For Windows, go to the git official website to Download git. After downloading git, you will get a command line tool called Git Bash.

Linux: Too simple for Linux, since the original Git was written on Linux and required only one line of code

1.sudo apt-get install git
Copy the code

Once installed, use git –version to check the version

2. Install nodejs

Hexo is written based on nodeJS, so you need to install nodeJS and the NPM tool in it.

Windows: NodeJS select the LTS version.

Linux:

1.sudo apt-get install nodejs
2.sudo apt-get install npm
Copy the code

After the installation, open the command line

1.node -v
2.npm -v
Copy the code

Check that the installation is successful

By the way, after installing Git on Windows, you can use git bash directly to type the command line without using CMD.

3. Install hexo

Once git and nodejs are installed, hexo is ready to install. You can create a folder called blog and then CD it to that folder (or right-click git bash to open it).

Type the command

1.npm install -g hexo-cli
Copy the code

Again, use hexo -V to check the version

This is the end of the installation.

Next, initialize hexo

1.hexo init blog
Copy the code

The blog can call itself whatever it wants, and then

1. CD blog // Go to the blog folder 2Copy the code

After the creation is complete, the following information exists in the specified folder:

Node_modules public: holds generated pages scaffolds: generates some templates for articlessourceYml: a config file for your articles themes: theme _config.yml: blogCopy the code

And then:

1.hexo g
2.hexo server
Copy the code

Open hexo’s service and type localhost:4000 into your browser to see your generated blog.

It looks something like this:

Use CTRL + C to turn off the service.

4. GitHub creates a personal repository

First, you need to have a GitHub account. Sign up for one.

After registering, you see a New Repository on GitHub.com. Create a New repository

Github. IO will be identified when it is deployed to github page in the future. XXX is the user name that you registered for Github. I already have one here.

Click Create Repository.

5. Generate SSH and add it to GitHub

Go back to your Git bash,

1.git config --global user.name "yourname"
2.git config --global user.email "youremail"
Copy the code

Where yourname is your GitHub username, youremail is your GitHub email address.

That way GitHub will know if you’re on its account.

Next: Use the following two to check if you have typed correctly

1.git config user.name
2.git config user.email
Copy the code

I’m going to create SSH, maybe y/n in the middle, make sure y is it, and then I’m going to basically press enter,

1.ssh-keygen -t rsa -C "youremail"
Copy the code

At this point it will tell you that the.ssh folder has been generated. Find this folder on your computer.

SSH is a secret key, in which id_rsa is the private key of your computer, which cannot be seen by others, and id_rsa.pub is the public key which can be seen by others. Put this public key on GitHub, so that when you link to GitHub’s own account, it will match your private key against the public key, and when it matches, you will be able to upload your files to GitHub through Git.

Then go to GitHub’s Setting for SSH Keys and click On New SSH Key to copy your id_rsa.pub information into it.

In gitbash, check to see if it succeeded

1.ssh -T [email protected]
Copy the code

So — — — — — — — — — — >Generally speaking, this interface is already successful, and it’s time to move on, guys.

6. Deploy Hexo to GitHub

In this step, we can associate Hexo with GitHub by deploying the hexo-generated articles to GitHub, opening the site configuration file _config.yml, flipping to the end, and changing to

YourgithubName is your GitHub account

  1.deploy:
  2.type: git
  3.repo: https://github.com/YourgithubName/YourgithubName.github.io.git
  4.branch: master
Copy the code

To do this, you need to install deploy-git, or the deploy command, so that you can deploy to GitHub using the command.

1.npm install hexo-deployer-git --save
Copy the code

then

1.hexo clean
2.hexo generate
3.hexo deploy
Copy the code

Where hexo clean cleans up the stuff you created before, or you don’t add it. Hexo Generate, as the name implies, generates static articles, which can be used as hexo G or hexo D to deploy articles

Note that you may be asked to enter username and password when deploy is deployed.

The image below shows that the deployment is successful and will be available in a few momentsyourname.github.ioThis website saw your blog!!

7. Set a personal domain name

Github. IO is a free domain name for your website. Your current address is yourname.github. But it costs money.

Register an Ali cloud account, buy a domain name on Ali cloud, what I buy is ranmoc.top, the price of each suffix is not quite the same, for example the most extensive.com is more expensive, see individual be fond of.

You need to go to the real name authentication, and then in the domain console, you see the domain name you bought.

Click parse to add parse.

Log in to GitHub, go to the repository created previously, click Settings > Page and change the branch to master by default. If not, set Custom domain to ranmoc. Top.

At this time, you url input your domain name, has been refreshing, 1-2 minutes, sometimes a few seconds is enough to see luck, domain binding site you can see oh!

So: Now you can start writing.

1.hexo new newpapername
Copy the code

Then open the markdown file in source/ _POST to start editing. When you’re done, then

1.hexo clean
2.hexo g
3.hexo d
Copy the code

You can see your blog post updated.

Time is limited, there will be a detailed update, there are a lot of details and errors will be shared with you, you can also discuss together in the comments section of the comment section, today is more about this, to know what happens next, please listen to the next time to continue the breakdown…

The attached: ———————————————————————————————————————— ———- I am untalented and uneducated, but also just contact, stepping on the big guy predecessors through the road, all kinds of learning, do not like light spray, thank you, small life this car polite.