Use GitHub to build a personal blog and github to build a blog

Source: Internet
Author: User

Use GitHub to build a personal blog and github to build a blog

1. Establish the environment

First, you need to download two things.

1. node. js

2. git

You don't need to talk about the specific download. Basically, you can download the default installation. Remember the installation path first. The following window is displayed during Git installation. Select the second one. In this way, you can perform Git operations in the Windows Command window.

After both are installed, open the command window (Press Win + R and Enter CMD to open the command window ), run the node-v, npm-v, and git-version commands to view the version of the software we just installed, the version number may be different.) Congratulations, you have already passed the environment setup challenge and you can proceed to the next step.

1.1 if you have any questions, see here.

Open the path of the software we just installed, such as my path "D: \ Program Files \ nodejs" and "D: \ Program Files \ Git ".

Copy the PATH we just installed, open the computer, right-click Properties, choose advanced system Settings> select environment variable> double-click PATH> append the PATH we installed to the variable value! Note the semicolon and confirm to save

In this case, try node-v, npm-v, and git-version commands.

2. Configure GitHub

2.1 register GitHub

Go to Sign up on the GitHub website to register an account.

Enter the username, email address, and password to go to the next step.

2.2 SSH authorization

After registering an account, we can view other people's projects or even clone downloads at will, but to submit code, we must complete SSH authorization. If we can submit code without authorization, so isn't Github messy.

2.2.1. generate an SSH key

Open Git Bash, enter ssh-keygen-t rsa, and press enter, as shown in

Then it will be in C: \ Users \ Administrator. the files id_rsa and are generated under the ssh directory. id_rsa is the key and is the public key. Next, add the content to GitHub, in this way, the local id_rsa key can be paired with the Public Key on GitHub before the authorization is successful.

2.2.2. Add an SSH Key on GitHub

Click the inverted triangle in the upper right corner to enter Settings.

Next, select SSH and GPG keys on the left, select New SSH key in the upper right corner, and copy and paste the content to the key ( can be opened using sublime or notepad ), add the SSH key.

After the SSH key is successfully added, enter the ssh-T for the test, if the following prompt shows that the addition is successful.

This step is generally okay. If you have any questions, leave a comment (by the way, I will enjoy it. Go directly to the next step!

3. Create a GitHub Repository

Note that the project name must use your name +. github. io

There is no problem with this step. If there is a problem, you must have not rewarded me)

4. Configure the local blog

4.1 install Hexo

Create a folder where you think it is appropriate, hold Shift + Right-click the blank folder, and click here to open the command line window. (Remember to use the command line in the current directory to represent the above operations)

Enter npm install-g hexo in the command line

Enter npm install hexo-save. At this time, you will see a bunch of white words in the Command window, and then enter hexo-v to check whether hexo has been installed successfully.

In the same situation, it means you are close to success.

4.2 initialize Hexo

In the command window, enter hexo init again.

In this case, we can open the browser and enter http: // localhost: 4000/in the address bar. This is our blog. That's right. Our blog is built like this. However, this is just our local blog. We need to consider how to upload our local blog to our GitHub.

Next, let's take a look at where our blog posts are. Open the source folder under our folder, you will find there is a _ posts folder, and then enter it will see an initialization of the article is displayed on the page of the article. If you want to create a new article, you can input hexo new 'filename' in the Command window. A new md file will be generated under our folder, and then you can open and edit the file.

4.3 publish a blog

First, copy our GitHub Project address, for example.

Open the _ config. yml file generated under the newly created folder and make the following changes at the bottom.

Deploy indicates deployment. type: git indicates deployment using git. repo: github repository address

Note: The repo is not originally available. You can add it yourself at the end. There is a space after the colon, followed by a space after the colon

Return to the Command window and enter npm install hexo-deployer-git-save

After installing the Git upload plug-in, input hexo g and then input hexo d to upload our blog to our GitHub, in addition, you only need to use these two commands to update the document later. So that others can access our blog through (start with https, yourname is your github name ).

5. personalized settings (change subject)

You may think that the default topic of this blog is really ugly. If you don't think you can ignore this step (haha ).

The topic I use is used as an example.

The first step is to find the desired topic and download it. I'm using the next topic, entering the git clone themes/next in the Command window

Open the configuration file and find theme to replace the default landscape with next. In the command window, enter hexo clean, hexo g, and hexo s, first check what the local blog looks like, and confirm that you have entered hexo d to deploy it to GitHub.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.