Migrate blog to Github(HTTPS) and add continuous integration



Continuous integration

Set Travis-CI account and Token

  1. Sign up Travis-CI and sync your Git-hub account:


  2. Choose your *github.io:


  1. Set Token:

    First step: check Settings


    Second step: find Developer settings


    Third step: generate your token (you can type any name you like) and check ‘repo’:



    Because the token just show once, you must record your token!! Otherwise, you’ll need to generate again.

  2. Add Environment Variable

    We can store the generated token as GH_TOKEN which will help us write .travis.yml file later.

    Environment Variable

Write config file

.travis.yml is the config file of Travis-CI . You need to generate one and push to the root of your Git-hub repository (*github.io).

Here’s the example of .travis.yml and you should change according to your own account:

language: node_js # 声明环境为node
node_js: stable

# Travis-CI Caching
    - node_modules # 缓存node_modules文件夹

# S: Build Lifecycle
  - npm install -g hexo-cli # 下载依赖

  - hexo g

after_script: # 推送到github的部分
  - cd ./public
  - git init
  - git config user.name "zxdawn"
  - git config user.email "xinzhang1215@gmail.com"
  - git add .
  - git commit -m "Update docs"
  - git push --force --quiet "https://${GH_TOKEN}@${GH_REF}" master:master # 通过之前存在Travis-CI里的token以及github仓库的地址推送到相应的master分支
# E: Build LifeCycle

    - master # 只对master分支构建

env: # 环境变量
   - GH_REF: github.com/zxdawn/zxdawn.github.io.git # 我的仓库地址

Add HTTPS to blog

I’ll explain how to add HTTPS to your blog, if you have your own domain name instead of *github.io.

You can add HTTPS easily and freely by Cloudflare

Use custom domain with GitHub Pages

You need to add your domain to GitHub according to GitHub tutorial.

  1. Set custom domain:

Custom domain

  1. Create A records that point your custom domain to GitHub IP:

    DNS server

Sign up Cloudflare account

Manage DNS

Type A points to Git-hub IP. Tyoe CNAME points www subdomain to apex domain.


Click ‘Next’ and change NameServer of your DNS server according to Cloudflare guide.


Turn on HTTPS

Turn on flexible SSL


Redirect traffic to HTTPS

If others visit my blog by http://dreambooker.site, how can I let them visit https://dreambooker.site directly?

We can use the function of Page Rules:

Page Rules

By the way, this method is the redult of communication between browser and server. We can use HSTS to make redirect safely and quickly. HSTS is under the menu of Crypto:


Say something

Thank you

Your comment has been submitted and will be published once it has been approved.


Your comment has not been submitted. Please go back and try again. Thank You!

If this error persists, please open an issue by clicking here.