Daniel Cano Merchán - Hacking & Tech

Host a static web using Github pages, custom domain and https

This post is about how to host a static web site on Github pages, using a custom domain and HTTPS.

Static site

First a static web site prepared to be deployed on any host.

Note: remember, a static web site is not using php, pythom, asp etc is only html,css and js. Dynamic content will not work

Github account

Second, a Github account to create a new public repository. This repository will be special because is designed to have one per free account and are limited.

The repository needs to have a special name, your username. Using my username as a example, u915 ,you need to create a new repository called u915.

You will be warned about using the same name as your username and it will create a special repository like:

	u915/u915 is a special repository. 
	Its README.md will appear on your public profile! Send feedback 

Once the site is created you can place any test plain file to probe the site, something like a default index.html

Clone the repository and test the site

git clone https://github.com/u915/u915.git
echo "it´s works" > index.html
git add --all
git commit -m "testing"
git push

Now there are a basic index.html prepared to be accesed via internet.

Check the repository configuration:

https://github.com/u915/u915 > settings  > Github Pages

Point the master branch or the branch you used to push the default index.html a similar message to this can be readed:

Your Github Pages site is currently being built from the master branch.

By default all the content is deployed on the special url:


Accesing the url will display the index.html

Custom domain

Third, a custom domain, example: u915.net.

Instead of the Github page url supplied, I want to use the site with a custom domain.

To do that is necessary to point the domain to the Github pages url.

So, when a custom domain u915.net is resolved will be pointed to u915.github.io

Enabling DNS

To do that, DNS must be configured pointing to the Github servers.

The Github urls on the day of this post have been written are:

On the domain provider add the Github urls with DNS A records and add a CNAME www pointing to the Github pages url, https://u915.github.io

This is my configuration:

alt text

Type | Host | Value | TTL
--- | --- | --- | ---
A record | @ | | auto
A record | @ | | auto
A record | @ | | auto
A record | @ | | auto
CNAME | www | u915.github.io | auto

When changes are confirmed, it is normal that the changes are not inmmediate specially if it is a new domain, the changes will have effect when the DNS are propagated.

There are some sites like: dnschecker.org where you can check the DNS propagation.

Or can be confirmed using dig

dig +noall +answer u915.net
u915.net.               1799    IN      A
u915.net.               1799    IN      A
u915.net.               1799    IN      A
u915.net.               1799    IN      A

Check the configuration and enable HTTPS

Add the custom domain using the repository configuration and Confirm that the custom domain can reach Github pages on the configuration page. Inside you can enforce to use HTTPS requests, Github will generate a special cert for the repository in a 3 phase action.

alt text

If there are any error or warnings will be appear on the same place (the configuration panel), if all is ok you will be rewarded with the green tick and the site will be accesible using the custom domain and https.

Thanks for reading.

The content of this post is a personal writeup of the process done, all is based of the Github documentation.

Source: https://docs.github.com