If you don’t want to use Jekyll as your static site generator for GitHub Pages and you want to have a custom domain for your GitHub Pages. This post is for you!
0. Dependencies
- Find a package manager for your current system and become familiar with it. I will use
brew
since I’m onmacOS
. brew install node git gh
or something similar for your package manager.- Using
gh
or the GitHub cli makes working with GitHub easier.
1. Fork Quartz
- You can either use
Quartz
as aTemplate
orFork
it.Template
: copy ofQuartz
as is, which might make keeping up withQuartz
updates slightly difficult. Updates will probably need a copy and paste ofQuartz
at the root. Managing changes this way is difficult.Fork
: easier to sync changes from the source. Any changes or modifications you make toQuartz
will becomemerge
conflicts when an update happens, which are easier to manage with the right tools.- I recommend a
Fork
. After you click onFork
, STOP.
2. Name your Quartz Fork
to initialize your GitHub Pages
- Since you can have only one public
Fork
of Quartz at a time, I used myFork
to create my GitHub Pages. - Under the
repo
name after you clickFork
, I enteredababber.github.io
. When you name your QuartzFork
repo
, replaceababber
with your GitHubusername
, which initializes your GitHub Pages. - According to GitHub, you only have one GitHub Page per username.
- Once the
Fork
is created. There are a few more steps before you’re live.
3. Setup Quartz locally
4. Setup Deploy in Repo
- In your favorite code editor, create a file called
deploy.yml
.- I recommend vscode.
- In the hidden directory
/username.github.io/.github/workflows/
, adddeploy.yml
- The content of
deploy.yml
is below:
5. Configure GitHub for Quartz Deploy
- Go to your Quartz
Fork
, which will be something like:https://github.com/username/username.github.io
. - Click on the
Settings
tab for therepo
. - In the left hand column, click on
Pages
. - Under
Build and deployment
in theSource
drop down menu, selectGitHub Actions
- We’ve already setup the workflow with
deploy.yml
. - At the bottom, select
Enforce HTTPS
if not selected.
6. Sync Content
- In
quartz.config.ts
, change thebaseUrl
property to your GitHub Pages root domain, which should be something likeusername.github.io
.
7. Setup Custom Domain with cloudflare
- Go to cloudflare
- Create an account.
- Search for a domain name.
- Register it (prices will vary depending on the domain name).
- From you
Account Home
go to the domain you just created. - Click on
DNS
and ensure you’re in theRecords
section. - Select
Add record
:- Type:
CNAME
- Name:
@
- Target:
username.github.io
- Select
Save
- Type:
- Select
Add record
:- Type:
CNAME
- Name:
www
- Target:
username.github.io
- Select
Save
- Type:
- For all the records that were created, ensure the
Proxy status
is OFF, we will enable this later. - On the left hand column of your custom domain page, click on
SSL/TLS
. - Ensure you are on the
Overview
section ofSSL/TLS
. - Click on
Configure
. - By default cloudflare sets
Custom SSL/TLS
toFlexible
. Change this toFull
.- We need to do this because
username.github.io
is being served to cloudflare overHTTPS
by GitHub. - If we don’t do this then your GitHub page may become unreachable and report the following error:
ERR_TOO_MANY_REDIRECTS
. This is caused by a conlict with theCustom SSL/TLS
Flexible
setting and the Github PagesEnfore HTTPS
setting which creates an unexpected feedback loop.
- We need to do this because
8. Set GitHub Pages Custom Domain
- Verify your custom domain with the following instructions.
- Go to
https://github.com/username/username.github.io
. - Click on your repo
Settings
tab. - In the left hand column, click on
Pages
. - Under
Custom domain
, enter yourcustomdomain.com
root. Don’t include the protocol or a subdomain. - Click on
Save
. - Wait on this page for GitHub to perform checks. If everything was setup correctly,
DNS check successful
will appear.
9. Final Things to Configure
- Go to your repo on your local machine.
- In
quartz.config.ts
change thebaseUrl
property to yourcustomdomain.com
root. - Sync changes to GitHub with:
npx quartz sync
. - Wait for the build and deploy to finish in your
username.github.io
repo. - Check if your
customdomain.com
is live. - Troubleshooting can be done in your
username.github.io
repoActions
andSettings --> Pages
tabs. - Once everything is live and working correctly, go back to your cloudflare account.
- Log in.
- Go to your
customdomain --> DNS --> Records
- Set
Proxy status
to ON for the previously createdCNAME
records.