Hexo builds a blog and pushes it to GitHub

Initial Hexo

npm install hexo-cli -g
hexo init blog
cd blog
npm install
hexo server

Browser access:http://localhost:4000/

Set up GitHub

1. First, register a Github account and create a new repository named.github.io, which is a new repository.

insert image description here
Because the blogger created it before, he cannot create it now. After creation, you can create a new index.html in your warehouse, in which you can enter a few characters at will and save it.

insert image description here
Select the settings option of the warehouse, and find pages in the menu bar, so that you can get your blog address.

insert image description here
Click Visit site or enter directly in the address bar to access the index.html file just written.

Push to GitHub

At the last step, you need to deploy the local blog project (create the blog folder yourself) to Github.

First modify the configuration file of hexo. Enter the project folder and open the _config.yml configuration file configuration parameters in the project root directory. Pull to the end of the file and fill in the following configuration.

insert image description here

deploy:
  type: git
  repository: https://github.com/yourname/yourname.github.io.git 
  branch: main

Install hexo-deployer-git automatic deployment release tool

npm install hexo-deployer-git --save

Finally, execute the following command to deploy and upload, and generate the page. The following g is the abbreviation of generate

hexo g

Local files are uploaded to Github, d is the abbreviation of deploy

hexo d

A login interface will appear in the middle, just log in to your Github account.

After a while, visit the URL in the browser: https://yourusername.github.io and you will see your blog! !

Reference: https://www.cnblogs.com/lanluoying/p/17208924.html

Guess you like

Origin blog.csdn.net/u014641168/article/details/130991672