Create a New Git repository

Create an empty repository on GitHub named “your username.github. IO”. The correct format of the repository name is github username. Github. IO.

At this point, you can get the warehouse address starting with [email protected] for the warehouse. Remember this warehouse address for later use.

What is a Hexo?

Hexo is a fast, concise and efficient blogging framework. In other words, with Hexo you can quickly build a beautiful blog of your own.

Install Hexo

Here are the specific installation steps:

  • Install the prerequisite
    • Node.js
    • Git

Make sure you have Node and Git installed on your system. If you already have the above prerequisites installed on your computer, you are ready to install Hexo.

npm instal -g hexo-cli
Copy the code

Once installed, Hexo will create the required files in the specified folder by executing the following command, which will create a new myBlog file, and Hexo will add the required files to myBlog

hexo init myBlog
cd myBlog
init i 
Copy the code

At this point, you will find a myBlog folder on your computer containing a number of files:

_config. Yml:

This file contains the configuration information of the site, you can set various parameters in it to adapt the configuration of the site. Such as:

Title: Site title

Subtitle: Subtitle of a website

Description: Website description

Author: Your name

Url: the url

Theme: the theme of a website

.

package.json

This file contains information about the application

scaffolds

Template folder. When you create a new article, Hexo creates a file based on that scaffold. Hexo’s template refers to what is populated by default in the new Markdown file. For example, if you modify the front-matter content in scaffold/post.md, this change will be included every time a new article is created.

source

The resources folder is where user resources are stored. Files/folders with names beginning with _ (underscore) and hidden files are ignored except for the _posts folder. Markdown and HTML files are parsed and placed in the public folder, while other files are copied over.

themes

Theme folder. Hexo generates static pages based on themes.

Create your first blog post

  • Type in the command: hexo new open wide, and you will see an MD file path:

    INFO Created: ~/Documents/myBog/source/_posts/ opendata.md

    Open the MD file and edit it. Save when finished.

  • Open the file _config.yml and edit:

    Change title to your desired site name, author to your name, type on the last line to type:git, and add repo to the repository address generated in the first step of the article on the bottom line of typeCopy the code
  • NPM install hexo-deployer-git –save

  • Deployment site hexo Deploy

  • Preview blog:

    Go to the “your username.github. IO” repo, open github Pages, if already enabled, click on the preview link, and you can see your own blog! Perfect!

Change your blog theme

Maybe you don’t like the current topic, that’s ok, change!

  • Hexo Topic collection
  • In the above subject casually pick a theme, and into its making homepage, such as the NexT, and then copy it to SSH address or HTTPS: https://github.com/iissnan/hexo-theme-next.git
  • cd themes
  • git clone https://github.com/iissnan/hexo-theme-next.git
  • cd ..
  • Change line 75 of _config.yml to theme: hexo-theme-next and save
  • hexo generate
  • hexo deploy
  • Wait another minute and refresh the blog to see the new theme! Perfect!

Upload the source code to Github

Note: since “your username.github. IO” stores only your blog and does not store “blog-generator”, you need to create an empty repository named blog-generator to store “blog-generator” in myBlog.

Create an empty repository of blog-generator on Github and follow its prompts.

This way, your blog code is stored in “your username.github. IO” and the blog code is stored in blog-generator so that data is not lost.

At this point, a hexo+ Github blog is complete, and you can play around with it and learn more!