Hosting a Jekyl blog on GitHub pages using a custom AWS domain
Introduction
Quick instructions on how to create a Jekyl blog via GitHib pages and redirecting your custom domain from AWS to it
Sources:
- https://benwiz.com/blog/deploy-github-pages-with-aws-route-53-and-https/
- https://christopherkade.com/posts/subdomain-githubpages
- https://talk.hyvor.com/blog/creating-a-static-site-blog-with-jekyll-and-github-pages/
Steps
1. Create new GitHub repository and enable GitHub Page
- Create a new repository using the following format:
<YOUR USERNAME>.github.io
. - Go to your newly created repo and go to settings.
- Scroll down to the GitHub Pages section and enable by selecting
Branch: main
. - Check Enforce HTTPS
2. Create a placeholder website
- Clone the repo
git clone https://github.com/<USERNAME>/<USERNAME>.github.io.git
. - Change directory
cd <USERNAME>.github.io.git
- Create a basic placeholder index.html
echo "Hello GitHub Pages!" > index.html
- Create a CNAME file with the domain you want to forward to
<DOMAIN> > CNAME
- Push to GitHub
git add . && git commit -m 'Initial commit - placeholder index and CNAME' && git push
3. Configure AWS Route 53 to point to your website
- Log into AWS console and go to the Route 53 dashboard
- Click Hosted zones
- Click the domain you would like to use
- Click Create Record
- Click Simple Routing > Next
- Click Define simple record
- For record name enter in the subdomain e.g.
blog.dominicst.com
- For Value/Route traffic from the drop-down menu select IP address or another value, depending on the record type. In the free text box enter in your GitHub pages URL i.e.
<USERNAME>.github.io
- For Record type select CNAME
- Select Define simple record
- Head to your domain to see if it loads your GitHub page.
4. Set up jekyll
- Install ruby
- Install Jekyl
gem install jekyll bundler
jekyll new .
- You might need to delete and remake the CNAME file.- Use
bundler exec jekyll serve
to run locally on http://localhost:4000 - Edit the config file
_config.yml
- Start creating blog posts in the _posts folder, file names should be in the
YEAR-MONTH-DAY-title.md
format