When I started my company, I was looking for a blogging platform that I can use easily and at the same time, it can be managed more easily. So the choice which I was learning towards was to have a Serverless Blogging website. Parameters were to have something on which I can easily write and I don’t have to do anything to manage the infrastructure of the website.
After going through many blogging platforms and reading a lot of articles, I’d decided to go with Jekyll
Jekyll is a simple, blog-aware, static site generator for personal, project, or organization sites. Written in Ruby by Tom Preston-Werner, GitHub’s co-founder, it is distributed under the open-source MIT license.
So Here’s a DIY article on how can you set up your own Serverless Blogging Platform with near to 0$ cost.
- First, we’ll need to install the gem
sudo apt-get install ruby-full build-essential zlib1g-dev echo '# Install Ruby Gems to ~/gems' >> ~/.bashrc echo 'export GEM_HOME="$HOME/gems"' >> ~/.bashrc echo 'export PATH="$HOME/gems/bin:$PATH"' >> ~/.bashrc source ~/.bashrc
Quick Start Instructions
Let’s get started with installation:
gem install bundler jekyll
This should install bundler and Jekyll which is required to set up your own blogging platform.
Create your Blogging website
Now, let’s create our own website.
jekyll new my_awesome_site cd my_awesome_site
Jekyll is a static file generator so we would have to build a site before we can view any content.
- Jekyll build would build the site and copy the new posts/contents into _site the directory.
- Jekyll serve would start a local webserver at http://localhost:4000
Alternatively, during the development time, you can run the below command to rebuild your website with every change which gets saved.
bundle exec jekyll serve # => Now browse to http://localhost:4000
Setting up a template
Being an OpenSource project, You would find a lot of pre-built templates which you can use for your blogging website.
Head to – JekyllThemes
A quick way to setup –
git clone https://github.com/daattali/beautiful-jekyll.git cd beautiful-jekyll/ sudo bundle install bundle exec jekyll serve
Now, that my blogging platform is ready, I want to deploy the website using my command line without me running serious upload operations.
So I set up my CI/CD Pipeline on Gitlab CI which would trigger every time I upload my blog into my GitLab repo.
This is how my .gitlab-ci.yml file looks like.
image: ruby:2.3 stages: - build - deploy cache: paths: - vendor key: "$CI_BUILD_REPO" before_script: - gem install bundler build_jekyll: stage: build only: - master script: - bundle install --path=vendor/ - bundle exec jekyll build artifacts: paths: - _site/ deploy_production: image: "python:latest" stage: deploy when: manual dependencies: - build_jekyll before_script: - pip install awscli # Install the SDK script: - aws s3 cp _site s3://$AWS_BUCKET/blog --recursive --exclude ".git/*" --exclude ".gitlab-ci.yml" --acl public-read - aws cloudfront create-invalidation --distribution-id $DISTRIBUTION_ID --paths "/blog/*" environment: name: production url: http://datavizz.in/blog
That’s all and my blogging setup was ready. In between, I didn’t cover how to create an S3 bucket and what configurations you should do to host your website on S3 which can be found [here]()
Don’t forget to leave down your review and do give me your comments on what you would like to see next!