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 init
the command:
$ hexo init blog
blog
Is the file you created folder name. cd to the blog
folder, 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 blog
folder contents as follows:
_config.yml
db.json
node_modules
package.json
scaffolds
source
themes
Cd terminal to blog
the folder vim
is 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 repository
back CoderLGL
into 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 blog
folder 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 deploy
still 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 generate
and hexo deploy
commands.
Then continue error. . . . . . . .
A look of resentment
Internet to find a lot of ways did not solve, and finally hexo clean
then hexo g
, hexo d
... it is so resolved, must be more here suggest that you try to look for solutions online.
hexo deploy
After the command is successful, the browser opens the URL http://CoderLGL.github.io
(will CoderLGL
replace your user name) can see and open http://localhost:4000
when 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 keys
whether or not there. If a file id_rsa.pub
or id_dsa.pub
is directly SSH key
added 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_rsa
and id_rsa.pub
two files.
Add the ssh key to the Github
Find Go To Folder ~/.ssh/id_rsa.pub
to open id_rsa.pub
the 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 key
the green button.
post article
Terminal cd to the blog folder, execute the following command to create a new article:
$ hexo new "postName"
Named postName.md
files in the directory will be built /blog/source/_posts
under the postName
file 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.