GitHub
GitHub Pages
You can create static sites with GitHub Pages:
- Create a repository and name it with the extension
github.io, for instancemysite.github.io - Push the content of your local repository
- Go to Settings -> GitHub Pages -> Select master Branch -> Click Save button
- If you don't want to use HTTPS, untick Enforce HTTPS
- You can visit your site checking the link on 'Your site is ready to be published at'
More info at GitHub Docs
Updating the website
- Edit the content of your local repo
- Push the changes
- GitHub will automaticaly integrate the update and deploy the new site
Adding a custom domain
Note: It is PARAMOUNT to follow the exact order of these steps.
- Select your repository
- Go to Settings -> Github Pages -> Custom Domain
- Enter the name of your naked domain in the text box and click Save
- A
CNAMEfile will be created in your GitHub repository. Don't forget pull that file into your local respository. - Add the following CNAME record in your domain register:
wwwpointing tomysite.github.io - Add the following A records as
@in your domain register :
- 185.199.108.153
- 185.199.109.153
- 185.199.110.153
- 185.199.111.153
- For Enforce HTTPS to work, you have to wait for a while:
Not yet available for your site because the certificate has not finished being issued. Please allow 24 hours for this process to complete. (mydomain.com)
- Refresh the page after a couple of minutes and tick Enforce HTTPS
Drawback
The SSL certificate will only work for the naked domain http://mydomain.com. This means that http://www.mydomain.com will trigger a nasty warning in the browser. To fix this issue there are two options:
- (Recommended) Create a forwarding rule in you domain host that redirect requests to www to your naked domain. In Google Domains you can achieve this by using Synthetic Records:
- Delete the CNAME record for www
- Go to section Synthetic records
- Subdomain forward - Subdomain: www -> Destination URL: mydomain.com
- Temporary redirect (302)
- Forward path
- Enable SSL
- Google Domains will complain with the following message, but just wait a couple of minutes and it will go away:
This synthetic record has an error and will not function correctly: The SSL Certificate for this domain hasn't been created yet. This process may take up to 24 hours to complete.
- (Less recommended) Change the name of your custom domain in GitHub pages from mydomain.com to www.mydomain.com, and then change it back to mydomain.com
- This will generate a new SSL certificate for www.mydomain.com. So, we have the original certificate for mydomain.com and the the new certificate for www.mydomain.com.
- However, the only certificate that will be auto renewed will be the one for the custom domain active in GitHub pages. The other one will expire in 3 months.