Fangyijie Wang

Configure custom DNS with Hexo

While using Hexo to set up a blog, the default domain name is [your-github-username] To use a custom DNS for your personal blog, Github requires you to create a file named CNAME in master branch of your repository. Since Hexo3, if you simply added the CNAME file manually it would be overwritten at deployment time. So you could use Hexo plugin: hexo-generator-cname.


$ npm install hexo-generator-cname --save

Add hexo-generator-cname to plugins in _config.yml.

$ plugins: hexo-generator-cname

##Configure domain name in _config.yml
Go to _config.yml file, and find the variable url. Configure your custom domain name like below.

url: http://[your-custom-domain-name]

When you run

hexo generate
again, a CNAME file containing your custom domain name configured just now in _config.yml will be created.

Then you need to login to your DNS provider and create a DNS CNAME record pointing hostname www to Here is a DNS provider I used before wanwang. It will take a couple hours to replicate default domain name with the custom one.