Navigate back to the homepage

Creating my blog with Gatsby and Github Pages

Edwin Torres
May 1st, 2020 · 2 min read

Alright! Today is a great day, many years after I lost my old blog, I’ve decided to start from scratch and create again one blog to publish my experiences and don’t fall in the inertia. Here I will describe my experience creating my own blog using Gatsby and Github Pages.

This article will be structured in

What you will learn?

  1. Overview of Gatsby and GitHub Pages
  2. Creating your project with Gatsby
  3. Publishing your project in Github Pages
  4. Adding Travis CI to automate the deploy process
  5. Next steps

1. Overview of Gatsby and GitHub Pages

First things first. Before to explain you, how to create your site I will tell you more about Gatsby and Github Pages, if you alreay know about them, go ahead to the next step.

Taken from the official website Gatsby is:

Gatsby is a free and open source framework based on React that helps developers build blazing fast websites and apps.

So we can use the power of React, GraphQL, Markdown and some data sources to create really fast web sites, re-using lots of plugins and publishing in many Web hosting, in my case I will deploy in Github Pages.

In other words Github Pages is a free option to deploy hosted repositories in Github, also it give us an easy way to automate this process with some platforms like Travis CI.

2. Creating your project with Gatsby

After I reviewd some tutorials and content in Internet, about how to create my own site with Gatsby, here are my steps.

  1. Follow the quick-start with Gatsby to install the gatsby-cli.
  2. Once you have installed the Gatsby CLI can create your Gatsby project based on some Gatsby templates. To be honest, the simplest way to create your own site is using a template instead of creating everything from scratch. Also you can find some examples made with Gatsby and other technologies.
  3. In my case I’ve created my site based on the beautiful narative theme. Once of the benefits of using this template are:
  • Really good structure to add author and post
  • Can be integrated with Contentful to create dynamic post instead of static post (commits in Github)
  • Can be integrated with Mailchimp to reuse tue Subscriptions for newsletter
  • The styles can be modifies based on the theme-ui
  • The metadata and social networks can be modified in a simple way.
  • Is open source.

If you want to see more templates, you can visit this link.

3. Publishing your project in Github Pages

I will no describe the step by step to publish your site in Github Pages, because in the official page is described really well. However I can provide you some learned lessons.

4. Adding Travis CI to automate the deploy process

In few words, Travis CI is

Easily sync your projects with Travis CI and you’ll be testing your code in minutes!

To be honest, this have changed my perspective and life when is needed to automate the deploy process based on commits in a branch. To deploy your site using Travis CI you need to create a .travis.yml file in your root folder project and add the next configuration.

1language: node_js
3 directories:
4 - ~/.npm
6 email:
7 recipients:
9 on_success: always
10 on_failure: always
12 - '12.13.1'
14 depth: 3
16 - npm run build
18 provider: pages
19 skip_cleanup: true
20 keep_history: true
21 github_token: $GITHUB_TOKEN
22 local_dir: public
23 on:
24 branch: master

You also can follow this article to get more details.

  • You can achieve the same result using Circle CI

5. Next steps

It’s hard to tell you all things you can do with Gatsby, however you can start reviwing:

Join our email list and get notified about new content

Be the first to receive our latest content with the ability to opt-out at anytime. We promise to not spam your inbox or share your email with any third parties.

More articles from Edwin Torres

Engineers Survival Guide

A set of notes from Engineers Survival Guide by Merih Taze, that I've found pretty insightful.

August 25th, 2022 · 4 min read

Atomic Habits

A set of notes from Atomic Habits by James Clear, that I've found pretty insightful.

August 21st, 2022 · 1 min read
© 2020–2022 Edwin Torres
Link to $ to $ to $