Part 1: Empowering Web developers. Creating Your First Gatsby Blog Site-A Git-Powered Guide to Markdown Blogs

October 17, 2023

For a guide on creating a dynamic blog using Gatsby and Markdown, view Part 2 here:
View Part 2

As web developers, you are constantly exploring ways to streamline your development process, especially when it comes to creating and managing blog sites. While Content Management Systems (CMS) have their merits, sometimes you want a more hands-on approach that gives you full control over your content and source code. That’s where Gatsby, a powerful and flexible static site generator, comes into play.

In this guide, we’ll walk you through the process of setting up your very first Gatsby blog site. But we’ll take it a step further by showing you how to manage your content entirely through Git source control and Markdown files. By the end, you’ll have a lightweight, developer-friendly, and fully customisable blog site at your fingertips. We hope to add value to web developers with this guide.

Before we dive into the technicalities, let’s talk about why Gatsby is a great choice for your blog site:

Why Web Developers Choose Gatsby?

  1. Speed and Performance:
    Gatsby generates static HTML files, making your site incredibly fast and efficient. No database queries, no server-side rendering – just pure speed.

  2. React-Powered:
    If you’re already familiar with React, you’ll find Gatsby’s development process seamless. Create dynamic content with ease.

  3. SEO-Friendly:
    Gatsby optimises your site for search engines out of the box, ensuring your blog gets noticed by the right people.

  4. Markdown Support:
    Gatsby natively supports Markdown, making it an ideal choice for content-focused sites.

  5. Git Integration: Gatsby seamlessly integrates with Git, allowing you to manage your content, design, and configuration through version control.


Before you start building your Gatsby blog, ensure you have the following prerequisites:

  1. Node.js and npm: Install Node.js and npm to manage packages and dependencies.
  2. Git: Make sure you have Git installed to manage your source code.
  3. Text Editor: Choose your preferred code editor, such as VS Code, Sublime Text, or Atom.

Setting Up Your Gatsby Project

Let’s get our hands dirty and start setting up your Gatsby blog:

Step 1: Create a Gatsby Site

In your terminal, run the following command to create a new Gatsby site:

npx gatsby new my-blog

Replace my-blog with your preferred project name.

Step 2: Navigate to Your Project

Change your current directory to the newly created project:

cd my-blog

Step 3: Start the Development Server

Launch the development server by running:

gatsby develop

This command will start a local development environment at http://localhost:8000.

Step 4: Customize Your Site

Open your project folder in your chosen code editor. You can customize your Gatsby site by modifying the files in the src folder. For instance, you can edit the src/pages/index.js file to change your site’s homepage.

Step 5: Create Your First Blog Post

Now, let’s create your first Markdown blog post. In your project folder, navigate to src/pages. Create a new folder called blog if it doesn’t exist. Inside the blog folder, create a new Markdown file for your blog post. You can name it whatever you like, for example, my-first-post.md.

Step 6: Add Content

Open your Markdown file and start adding your blog content. You can use Markdown syntax to format your post. Here’s a simple example:

title: My First Blog Post
date: "2023-10-17"

# Welcome to My First Blog Post

This is your content in Markdown format. You can include headers, lists, images, and more.

Step 7: View Your Blog Post

Go to your browser and visit http://localhost:8000/blog/my-first-post. You should see your first blog post live!

Git Source Control Integration

Now that you’ve created your Gatsby blog and added your first blog post, let’s integrate it with Git source control.

Step 1: Initialize a Git Repository

In your project folder, run the following commands to initialise a Git repository:

git init
git add .
git commit -m "Initial commit"

Step 2: Create a Remote Repository

Create a remote repository on a platform like GitHub or GitLab. Follow their instructions for creating a new repository.

Step 3: Link Your Local and Remote Repositories

Link your local repository to the remote one by running:

git remote add origin <repository-url>

Replace <repository-url> with the URL of your remote repository.

Step 4: Push Your Code

Finally, push your code to the remote repository:

git push -u origin master

Congratulations! You’ve successfully set up your first Gatsby blog site and integrated it with Git source control. This combination allows you to easily manage your content, track changes, and collaborate with others.

By choosing Gatsby and using Markdown files, you have full control over your blog’s design and content, and your site is fully optimised for speed and SEO. It’s a win-win for web developers who want a flexible, developer-friendly, and high-performance blogging solution. Start creating, writing, and sharing your content with the world today!



Digital Agency Cape Town

© 2023 | Trinity Managed Solutions (PTY) LTD
Privacy Policy