Daniel Doubrovkine bio photo

Daniel Doubrovkine

aka dB., CTO at artsy.net, fun at playplay.io, NYC

Email Twitter LinkedIn Github Strava

Github has been petitioned, begged and implored to enable SSL on custom domains running on Github pages. It looks like they are finally and quietly delivering SSL support with LetsEncrypt certificates being deployed.

Please be aware that it hasn’t been officially released, this is why I have migrated two small Jekyll sites and not this blog, for example. YMMV.

This is what I had to do for my Github pages Jekyll site at https://www.dblock.org. You can see the changes in www.dblock.org@5f6f047d.

_config.yml

Change url in _config.yml to https://www.dblock.org to fix asset and other internal links.

I couldn’t figure out how to make those relative to either HTTP or HTTPs.

_includes/_enforce_ssl.html

Add a JavaScript redirect to _head.html from HTTP to HTTPs.

<script language="javascript">
  // Enforce SSL
  (function (root) {
    "use strict";
    var h = root ? root.location.hostname : "",
    p = root ? root.location.protocol : "";
    if ("http:" === p && !(/^(localhost|127.0.0.1)/).test(h)) {
      root.location.protocol = "https:";
    }
  }
  ("undefined" !== typeof window ? window : this));
</script>

I couldn’t find a plugin that could make a 301 redirect before page load, something that Google recommends.

_includes/_head.html

Include the JavaScript.

{% include _enforce_ssl.html %}