At the beginning of this article, I recorded some of the problems and pitfalls I encountered when building my blog on Mac using Hexo and Github. I hope it helps.
#### preparation ##### 1. Git ##### 2. Node. js used to generate static pages
Since git comes with Mac, we only need to download and install Node.js.
nodejs.org/en/
#### Create Hexo empty directory for ##### 1. Install node.js git and node.js to install Hexo.
$ sudo npm install -g hexo
Copy the code
Press Enter to enter your MAC login password
2. The initialization
From terminal CD to the folder name you created, execute:
$ cdThe file pathCopy the code
Then execute:
$ hexo init
Copy the code
3. Perform installation:
4. Run the following command to enable the hexo service:
5. Execute generate static page:
$hexo init ($hexo init, $hexo init, $hexo init) If the installation fails in some areas, you need to climb over the wall. ($hexo s) The installation is successful. If the installation succeeds, visit http://localhost:4000 in the browser.
Associated with making
##### 1. Obtain the SSH key
To check whether the SSH key exists, run the following command:
$ ls -al ~/.ssh
Copy the code
If there are files id_rsa.pub and id_dsa.pub, run from point 2
1. Generate an SSH key:
Press Enter to see the following image:
###### can use Weibo as the chart bed or Seven niuyun as the chart bed. Here I use seven Niuyun as the chart bed: www.qiniu.com/
2. Open Github and add an SSH key to Github
Github –> Settings –> SSH Keys –> add SSH Keys **
Key values can be copied using terminal commands:
$pbcopy < ~/. SSH /id_rsa.pub ' '**' 'Title', 'Add Key', 'Add Key##### 3. Create a Github library! [] making library (http://upload-images.jianshu.io/upload_images/1106602-7f314c7643d52168.png? ImageMogr2 /auto-orient/strip% 7cImageView2/2 /w/1240) ** Create library name as your login name :**! [name.github.io](http://upload-images.jianshu.io/upload_images/1106602-6f8469739d001f97.png? imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)##### 4. Open the Github client** I used the Github client for the first time herecloneOf course you can use the command line at the terminalclone* *! [Github](http://upload-images.jianshu.io/upload_images/1106602-2db89c4cdba4399d.png? ImageMogr2 /auto-orient/strip% 7cImageView2/2 /w/1240) **Clone the name you created on Github. Github. IO#### Set Hexo theme:
<br />
``` bash
$ cdLocal directory ' '**' 'execute the following command (which is a theme):**' ' 'bash $gitclonehttps://github.com/iissnan/hexo-theme-next them ` ` ` specific configuration method can refer to the official documentation http://theme-next.iissnan.com/ * * * * - - -#### Binding domain name:** I am here in Ali cloud to buy the domain name **! Aliyun (http://upload-images.jianshu.io/upload_images/1106602-523c470096ef185e.png? imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)##### 1. Open the TERMINAL CD to the local repository.
<br />
``` bash
$ cd blog
Copy the code
2. Create a CNAME file.
##### Copy the contents of the Hexo folder public folder into your clone folder (key step) as shown below:
#### 3. Perform the following operations: 1. Trace new files add all public files to the cache as follows:
bash $ git add CNAME
2. View the file status:
$ git status
Copy the code
3. Instructions for submission:
$ git commit -m ** ' ' 'bash $git push origin master' 'Copy the code
$ hexo d
Copy the code
Then copy the puclic file to clone to Github and execute the commit code from 3.
So far, a simple Hexo + Github blog is complete, but you can also use the official documentation to create your own cool blog. This is my personal blog http://chencha.ren