Based on GitHub to build the Hexo blog on Mac

After an afternoon of struggle finally use GitHub to build a blog of their own, record your own build steps.

Which uses the technology if we are interested you can understand the next:

Environment Configuration

Hexo official website on this there is a detailed description Hexo to install and use, it is recommended. Here to tell their own personal steps to install or different.

Node.js

Used to generate static pages. Venue Node.js official website , download, all the way to install.

Git

To be submitted to the local Hexo content on Github. Xcode comes with Git, not repeat them here. If you do not Xcode can refer to the official website Hexo installation method.

Installation Hexo

When after Node.js and Git are installed can be formally installed Hexo, the terminal execute the following command:

$ sudo npm install -g hexo

Enter the administrator password (Mac password) that is to start the installation ( sudo: Linux system administration commands -g: Global installed)

Note: HEXO official website of the installation command $ npm install -g hexo-cli, do not forget that preceded the installation sudo, or because of being given permission issues.

initialization

Terminal cd to a directory of your choice, execute hexo initthe command:

$ hexo init blog

blogIs the file you created folder name. cd to the blogfolder, run the following command to install npm:

$ npm install

Run the following command to open hexo server:

$ hexo s

In this case, the browser open the URL HTTP: // localhost: 4000 , can see the following page:

After the local set, then began to associate Github.

Associated Github

Creating a warehouse

Log in to your Github account, the new warehouse, known as fixed user name .github.io written, as shown in the following figure CoderLGL.github.io namely:

Local blogfolder contents as follows:

_config.yml 
db.json 
node_modules 
package.json
scaffolds
source
themes

Cd terminal to blogthe folder vimis opened _config.yml, the following command:

$ vim _config.yml

After opening the sliding down to the end, modified to look like the following:

deploy:
  type: git
  repository: https://github.com/CoderLGL/CoderLGL.github.io.git
  branch: master

You will need to repositoryback CoderLGLinto your own user name.

Note: When configuring the _config.yml all files (including the theme), in all of the colon: a space behind to be, otherwise hexo command error.

In the blogfolder directory execute command generate static pages:

$ hexo generate     或者:hexo g
此时若出现如下报错:
ERROR Deployer not found: git

则执行命令:
npm install hexo-deployer-git --save  

若无报错,自行忽略此步骤。

And then execute the configuration command:

$ hexo deploy           或者:hexo d

Note: If the statistics do hexo deploystill error: unable to connect or can not find the git git, then execute the following command to install HEXO-Deployer-git :

$ npm install hexo-deployer-git --save   

Performed again hexo generateand hexo deploycommands.

Then continue error. . . . . . . .

A look of resentment

Internet to find a lot of ways did not solve, and finally hexo cleanthen hexo g, hexo d... it is so resolved, must be more here suggest that you try to look for solutions online.

hexo deployAfter the command is successful, the browser opens the URL http://CoderLGL.github.io(will CoderLGLreplace your user name) can see and open http://localhost:4000when the same page.

In order to avoid troubles Github each input user name and password, and can be referred to the second method

Add ssh key to Github

SSH keys to check whether there is

Run the following command to check SSH keyswhether or not there. If a file id_rsa.pubor id_dsa.pubis directly SSH keyadded to Github, otherwise enter the next generation SSH key.

Generate a new ssh key

Execute the following command to generate public / private rsa key pair, attention will be [email protected]replaced with your own e-mail address registered Github, all the way to press enter, do not fill anything in this step.

$ ssh-keygen -t rsa -C "[email protected]"

Default (in the corresponding path ~/.ssh/id_rsa.pub) to generate id_rsaand id_rsa.pubtwo files.

Add the ssh key to the Github

Find Go To Folder ~/.ssh/id_rsa.pubto open id_rsa.pubthe file, which is the information SSH key, copy this information to the Add SSH key to Github page of.

进入Github –> Settings –> SSH keys –> add SSH key:

Title to add a title in any of the copied content pasted into the Key, click on the bottom of Add keythe green button.

post article

Terminal cd to the blog folder, execute the following command to create a new article:

$ hexo new "postName"

Named postName.mdfiles in the directory will be built /blog/source/_postsunder the postNamefile name, for the convenience of the link is not recommended for doping characters. Of course you can use Markdown compiler to write articles.

After the article editing is complete, terminal cd to the blog folder, execute the following command to publish:

hexo generate           //生成静态页面

hexo deploy         //将文章部署到Github

At this point, build on Github-based Mac's Hexo blog is complete. The following describes how to install theme and content is binding personal domain, and if there is interest and patience, please continue it.

Install theme

You can go to Hexo official website topic page to search for their favorite theme. Here at NexT example, you can view the NexT document customize your favorite features.

Thanks to the guidance of the wedding day of the blog .

Guess you like

Origin www.cnblogs.com/LGLblog/p/10950754.html