use custom domain with hexo && how to reset to origin

Use custom domain to your blog built on Hexo

If you want use your own domain name instead of the one (xxx.github.io) given by github, the following steps should be taken.

  1. Get your git page’s ip

    1
    2
    ping xxx.github.io
    //change the xxx on your own

    PING
    The return XXX.XXX.XXX.XXX is the ip you need.

  2. Configure DNS Setting
    DNS Configure
    The operation for different provider varies, you should figure it out on your own.
  3. Create CNAME file
    Change to hexo directory, create a CNAME file under source directory. Add your custom domain to the file
  4. Things get done via the following commands

    1
    hexo clean && hexo g && hexo d

    After this, when you enter the xxx.github.io into your browser, it will automatically redirect to your own domain. And if you enter your own domain, the browser will show you your blog content.

How to reset to original domain given by github

If you want to reset the domain, you can achieve it by doing following steps

  1. Change directory to your repo, and clean it

    1
    hexo clean
  2. Edit your CNAME file, leave it blank or just delete it

  3. Finished via commands

    1
    hexo g && hexo d
  4. Then you could check out whether it works by entering your original url(xxx.github.io) into browser. If it doesn’t redirect to your custom domain and it shows contents instead of 404 page, it means it works.

  5. One more thing: if you don’t want your custom domain link to your blog, you could just configure the DNS and remove the relative rule.
    That’s all for this tutorial.