GitLab Pages vs. GitHub Pages

Related: tips for academic / professional web profile pages


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
  • GitHub Pages is substantially easier to setup and use, and is capable of medium websites getting several million hits / year
  • GitLab Pages (setup described below) has more features and flexibility for advanced users

GitLab Pages quick setup

  1. create a new GitLab Project named username.gitlab.io (put your GitLab username in for “username”)
  2. [if you already have a GitHub Pages website] Import from GitHub 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

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.

For frequently updated, medium sized websites (hundreds or thousands of pages) it can be better to build the site locally on your PC or on a CI and then deploy to GitLab, because you can run out of free GitLab Runner quota before the month is over.

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

Tags: ,

Categories:

Written by Michael Hirsch, Ph.D. //

Comments