I finally created my own blog last week. Because I had been learning Node.js recently, I wanted to try to use a platform built on it. First I found Ghost. But it seemed hard to create a Ghost blog with GitHub Pages. Then I found Hexo. It looked like exactly what I wanted. Simple and stylish.
Although there are so many tutorials of setting up Hexo and GitHub Pages, I think it is better to write down how I create my blog, and I hope it will help you.
Prerequisites
Before installing Hexo, Node.js and Git should be installed on your Mac. Please follow setup guides on their official websites.
Installing and Initializing Hexo
Now, Hexo can be installed with npm
.
|
|
Then, initialize Hexo. Here BLOG
is the directory for your blog.
|
|
Next, move to the directory.
|
|
Then, run the installation command.
|
|
Next, start the server.
|
|
Now, open http://localhost:4000 in your browser.
Hello World!
Hosting on Your GitHub Account
Now, create a new repository named YOURUSERNAME.github.io
on GitHub, replaceing YOURUSERNAME
with your GitHub username.
Then, add lines into _config.yml
in BLOG
.
|
|
Next, generate static files.
|
|
Then, deploy your blog.
|
|
If you meet ERROR Deployer not found: git
, run the command below.
|
|
Then, run generate and deploy commands again.
|
|
Now, open http://YOURUSERNAME.github.io
in your browser. For me, it is http://dryear.github.io
Hello World!
Configuring Your Own Domain
I bought my own domain from GoDaddy, and I chose DNSPod as my DNS hosting provider because of my friends in China.
After setting up on both GoDaddy and DNSPod, create a file named CNAME
in BLOG/themes/YOURTHEMENAME/source
, add your own domain in it. For me, it is dryear.me
.
Then, run the commands below to deploy again.
|
|
Now, open your own domain in your browser.
Hello World!