Sujay Kundu

Sujay Kundu

Sujay Kundu is a Certified Web developer and Digital Marketing Expert. He is currently working as Nodejs Developer at Katerra. Know more about him..

Deploy your jekyll blog using Github Pages and Travis CI

Posted on May 22, 2019

In this Guide, we are using Github Pages and Travis CI for deploying our blog. Sometimes Github Pages does not support external third party plugins. In that case we deploy our blog using Travis CI, it automatically builds our website and pushes the static files of the site to a deployment branch. Which then Github Pages uses to render the site. Hope you get it :P !

We might need to instruct Travis CI to follow deployment instructions. Copy the below content in.travis.ymlfile:

    language: ruby
    cache: bundler

    # Travis will build the site from gh-pages branch
    # and deploy the content to master branch
    # use gh-pages branch to serve for github pages
    # master branch will be used for deployment

      - gh-pages
      - JEKYLL_ENV=production bundle exec jekyll build --destination site

    # You need to generate a Personal Access Token
    # Add this token in environment variable GITHUB_TOKEN in Travis CI repo settings

      provider: pages
      local-dir: ./site
      target-branch: master
      name: Deployment Bot
      skip-cleanup: true
      github-token: $GITHUB_TOKEN
      keep-history: true
        branch: gh-pages

    # Generate your secure token with the travis gem:
    # get Github token from your Travis CI profile page
      gem install travis

    # env:
    #   global:
    #     secure: Example

All we are doing is telling Travis to pick up files from our gh-pages branch and push the build files to master branch.

Generate a New Github Personal Access Token

We need this token as a Environment Variable in Travis. For Travis can automatically login as you, and finish its job of building your site and pushing it to your repo’s master branch.

Go to Github Generate a New Token Page.

deploy using travis{:class=“img-fluid”}

Create a new Access Token

deploy using travis{:class=“img-fluid”}

Configure Travis

Go to Travis and Toggle the repository access to use Travis

deploy using travis{:class=“img-fluid”}

Go to the repository settings page and Add Environment Variable ‘GITHUBTOKEN’ ![deploy using travis](,,w600/v1592685627/ {:class=“img-fluid”}

Push your changes to Github

Commit your local changes in gh-pages branch

git add .git commit -m "added new post"git push origin gh-pages

After push, Travis will automatically run a build process and deploy your blog.

deploy using travis{:class=“img-fluid”}

You can visit your site at

deploy using travis{:class=“img-fluid”}

Done ! Enjoy your brand new devlopr-jekyll blog. You can visit the site at