This is the third day of my participation in Gwen Challenge

First, LET me show you my finished product:wanghao221.github.io/ There are two types of blogs to build, one is hosted on Github, represented by Hexo, and the other is to rent a server, mainly using the wordpress framework. There’s no need to buy your own server. Here’s how to use Hexo to build a personal blog.

Hexo supports Markdown and uses Markdown to write articles. (Typora, a Markdown editing tool, can be downloaded from the official website. The final result is a static HTML page that can be published to the server, providing natural access efficiency.

You need to have a GitHub account first. If you don’t have one, you can register at github.com/join

1. Download the Git

Windows:

Git-scm.com/download/wi… (Download from official website)

Linux:

sudo apt-get install git
Copy the code

Once installed, check the version by clicking Git Bash Here, Git –version

2. Install nodejs

Windows:

nodejs.org/en/ (Download from the official website of Windows8 and above)

Nodejs.org/download/re… (windows7 version download)

Linux:

sudo apt-get install nodejs
sudo apt-get install npm
Copy the code

After the installation is complete, right-click Git Bash Here and display the version number

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

npm install -g hexo-cli
Copy the code

Don’t panic if you don’t respond at first, after a while you’ll be like me, showing 35 seconds to install successfully.

Then use hexo -V to view the version

At this point, all the software you need to install has been installed. Let’s initialize hexo

hexo init hexoblog
Copy the code

This hexoblog can take whatever it wants, and then

cd hexoblog // Go to the hexoblog folder
npm install
Copy the code

Open the folder and you will see the following directory node_modules: dependencies public: to hold the generated pages scaffolds: some templates for generating articles Source: to hold your article themes: theme _config.yml: config file for your blog

hexo g
hexo server
Copy the code

Then type in your browserhttp://localhost:4000 The following information is displayed Use CTRL + C to turn off the service

4. GitHub creates a personal repository

Github. IO is a repository with the same user name as yours. Github. XXX is the user name you signed up for GitHub. Here I created a new GitHub account called pai-daxing1Click Create Repository.

I forgot to add.github. IO. I renamed it again

5. Generate SSH and add it to GitHub

Go back to your Git bash,

git config --global user.name "yourname"
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. Here my username is pai-daxing1 and my email address is [email protected]. Type it in like I did

git config --global user.name "pai-daxing1"
git config --global user.email "[email protected]"
Copy the code

Then create SSH and just press Enter

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

Don’t forget to change youremail to your own

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

At this point it will tell you that the.ssh folder has been generated. Find the folder C:\Users\ administrator.ssh 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 and click New SSH Key

Copy the information in your ID_rsa. pub. (Right click to open notepad)Click Add SSH key and enter your GitHub login password

In gitbash, check to see if it succeeded

ssh -T git@github.com
Copy the code

Ask if you are sure in the middle and type yes

6. Deploy Hexo to GitHub

In this step, we can associate hexo with GitHub by deploying the hexo-generated articles on GitHub, opening the site configuration file _config.yml, and changing it to pai-daxing1 is your GitHub account

deploy:
  type: git
  repo: https://github.com/pai-daxing1/pai-daxing1.github.io.git
  branch: master
Copy the code

== Note that there is a space between type: and gihub.

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

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

then

hexo clean
hexo generate
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.My computer suddenly asked me to install this, so I installed it. I don’t remember when I first built it.

The image below shows that the deployment is successful, and you should see your blog later at yourname.github. IO!

Click on the authorization

pai-daxing1.github.ioOpen is like this, after I say how to optimize beautiful, in fact, I do not want to use it to write blog, just want to put some of their own want to put things on it, such as put some HTML games, as a graph bed, or use it to do my SEO layer chain and so on. Making address:Github.com/pai-daxing1…

More content

  • Build your own blog based on Hexo and GitHub
  • Java backgammon game contains free source code
  • Free and easy to use GIF recording software LICEcap