Home Host Jekyll Blog on AWS
Post
Cancel

Host Jekyll Blog on AWS


Introduction

Hosting a Jekyll website on AWS S3 is a cost-effective and reliable way to deploy a static website.

[Good to know vocabulary]
S3 Bucket: storage container provided by AWS

[Links]
Homepage: https://aws.amazon.com/


0. Prerequisites

1. (Can Skip) Create an S3 Bucket

In this section I will manually coinfigure S3 Bucket, however, this step can be skipped and configured automatically with s3_website_revived tool later.

Login to AWS -> Go to S3 Console -> Create Bucket

image-20230219224458791

  • Add Bucket name (Bucket names can consist only of lowercase letters, numbers, “ . “ and “ - “)
  • Select Region close to you

Once Bucket is created -> Open Bucket -> Permission -> Edit Block public access (bucket settings)

image-20230219231805807

S3 Bucket is now ready to use.


Create API credentials in AWS

Go to AWS IAM console -> Users -> Add Users -> Create a new user and grant permissions to the S3 and CloudFront services

image-20230306001022716


Install S3_website

The easiest way to configure Jekyll is to use this great s3_website_revivid gem

image-20230924001232262

1
gem install s3_website_revived

image-20230923233724634

Check s3_website command is available and if it’s not check the Ruby gem bin directory is included in the PATH, by modifying zshrc file (if using zsh).

1
nano ~/.zshrc

Add the following line

1
export PATH="$PATH:$(ruby -e 'puts Gem.user_dir')/bin"

Save the file, exit, and reload shell profile

1
source ~/.zshrc

To verify that the s3_website directory is in PATH

1
echo $PATH

Configure S3_website

Generate configuration file in jekyll website directory. This will create “s3_website.yml”

1
s3_website cfg create

image-20230924000011522

Edit s3_website.yml

1
2
3
4
- your AWS credentials   # or remove the first two lines to have credentials read from the environment variables AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY
- S3 bucket name
- s3_endpoint: eu-central-1   # specify s3 location close to you. Can check available values here https://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region
- site: # S3_website will automatically discover websites in the *_site* and *public/output* directories

Run the command to configure bucket to function as an S3 website. If the bucket does not exist, the command will create it for you.

1
s3_website cfg apply

image-20230924000523844

As a last step, push your website to S3

1
s3_website push

image-20230924002647024

The Site is now created in AWS and publicly available.

image-20231012233354474

image-20231012233324232


Update S3_website content

To push updates to the S3 hosted webiste, rebuild the jekyll site locally and run s3_website push again

1
2
jekyll build
s3_website push
This post is licensed under CC BY 4.0 by the author.

Deploy Website with Cloudflare Page

Basics of Environment Variables

Comments powered by Disqus.