Reference
Continuous integration
Set Travis-CI account and Token
Sign up Travis-CI and sync your Git-hub account:
Choose your *github.io:
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.
Add Environment Variable
We can store the generated token as
GH_TOKEN
which will help us write.travis.yml
file later.
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
cache:
directories:
- node_modules # 缓存node_modules文件夹
# S: Build Lifecycle
install:
- npm install -g hexo-cli # 下载依赖
script:
- 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
branches:
only:
- master # 只对master分支构建
env: # 环境变量
global:
- 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.
- Set custom domain:
Create A records that point your custom domain to GitHub IP:
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
:
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.
OOPS!
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.