Build Jekyll site on laptop then push to GitHub/GitLab Pages

TODO: comments and stats didn’t work

For GitHub/GitLab Pages, you don’t have to use GitLab/GitHub to build your site. You can build your site on your laptop, then push the rendered website HTML. Why do this? Your laptop builds faster than the cloud, or maybe you figure since you’ve just built the website preview on your laptop, why not ensure others see exactly what you see. This also allows using non-Jekyll static renderers on GitHub, which allows only Jekyll builds. (GitLab allows any static site renderer).

Assuming you’ve already created a Jekyll website, here’s how to switch to rendering HTML on your website and disabling remote rendering. Note: deploying on GitLab still uses Runner minutes, but obviously many fewer minutes overall than remote building.


GitLab Runner is reconfigured simply deploy your laptop-rendered HTML by:

  1. backup old .gitlab-ci.yml
   mv .gitlab-ci.yml .gitlab-ci.yml.disabled
  1. create new .gitlab-ci.yml
     - mkdir .public
     - cp -r * .public
     - mv .public public
       - public
     - master


If this is your first build, do the “first build only” first.

  1. update packages
   bundle update
  1. build HTML
   jekyll build -d public
  1. push rendered HTML i.e. git push

First build only

  1. get prereqs
   apt install ruby-dev libssl-dev
   gem update --system
  1. be sure Gems are installed to home directory, NOT system (no sudo) by adding to ~/.bashrc:
   # Install Ruby Gems to ~/gems
   export GEM_HOME=$HOME/gems
   export PATH=$HOME/gems/bin:$PATH
  1. Add HTML output directory to Git tracking
   mkdir public
   git add public


Running out of GitLab Runner minutes

GitLab Runner minutes are limited to 2000 minutes for free users on private repos. Runner minutes are unlimited for public repos. Normally I recommend a private repo for GitHub/GitLab pages, but if it’s OK for your use, you could make the website project public. You could store the website Jekyll source in a private GitLab repo, and push the rendered HTML to a public GitLab repo.