GitLab Pages vs. GitHub Pages

2 minute read

GitLab Pages vs GitHub Pages: feature matrix

feature GitLab GitHub
site generator any Jekyll only
Jekyll plugins any only whitelisted
domain aliases multiple only one

We recommend GitHub Pages-based website setup for websites of all sizes, including academic / professional web profile page. However, for reference below is the more complicated GitLab Pages setup for advanced users that have a reason to use GitLab Pages over GitHub Pages.

GitLab Pages quick setup

  1. create a new Project named username.gitlab.io (put your GitLab username in for “username”)
  2. Import from GitHub (or other) OR create/copy in your existing static website (if you had a GitHub Pages website, copy it here). If the latter, clone to your PC.
  3. on the GitLab project page e.g. https://gitlab.com/username/username.gitlab.io click Set up CI
  4. you’re automatically creating a .gitlab-ci.yml file. Under the “apply a GitLab CI Yaml template” pick appropriate for your site. If you’re coming from GitHub Pages it’s probably Jekyll.
  5. Your site is now building, as seen with the Pipelines tab of your website project. It takes about 3-4 minutes to install the gems for a Jekyll site, then 2-3 more minutes to complete the build depending on the size of your website. The public URL should be username.gitlab.io. If it’s not found, be sure you name your repo username.gitlab.io
  6. Once you can browse username.gitlab.io, in your Project Settings → Pages add TWO new domains if you have paid for your own domain name (here using example.com)
    example.com
    www.example.com
    
  7. This step can take your website down–do this at low traffic times. Once you’re satisfied it works, you can setup/transfer DNS to GitLab. Suppose your domain is example.com, then set your DNS records to
    example.com CNAME username.gitlab.io
    www         CNAME username.gitlab.io
    

    assuming your DNS provider supports CNAME flattening such as Cloudflare.

SSL Config

GitLab Pages used with for example Cloudflare works well to provide HTTPS with your custom domain name as per this procedure. With that procedure you can enable SSL “Full (Strict)” security.

Update limits

The free GitLab accounts currently give 2000 minutes/month build “pipeline” time. For a moderate sized website, let’s assume 5 minutes build time. So you could do 400 pushes/month or 13 pushes/day on average–that should be enough for a small to moderate website. You can cancel pipelines / runs to save wasted builds if you made a push and then are making another push right after.

This limit becomes a key reason to use GitHub Pages instead if the website is updated frequently as GitLab shared runners are quite slow vs. GitHub.

Private source repo

Both GitLab and GitHub allow the source files (e.g. Markdown) to be private for a public website.

GitHub requires a paid subscription to have one or more private repos, while GitLab gives free private repos.

You should have a private website repo. Otherwise Google may present search results from your website repo Markdown code instead of or alongside the rendered webpages!

Notes

  • You could build on your laptop (or cloud service like Wercker) with any static generator such as Hugo and push HTML to GitHub Pages.
  • Useful Jekyll plugins that GitHub doesn’t whitelist include jekyll-archives (page per category/tag)
GitHub GitLab
repo project

Leave a comment