The Complete Guide for Building Ultra-Fast Gatsby Websites

The Complete Guide for Building Ultra-Fast Gatsby Websites
Sumeet Shroff
Sumeet Shroff
August 7, 2023

How are you? My name is Sumeet Shroff, and I run a website design company called "Prateeksha Web Design." We use ReactJS and Gatsby to make websites that load very quickly. Let me tell you how making website performance a top priority changed my business and how it affected both user experience and search engine optimisation (SEO).

The best decision I made when I started my web design business was to use Gatsby to make websites load faster. By using Gatsby and optimising for performance, I was able to completely change my clients' websites and give their businesses a huge boost.

When I first started working in this field, I specialised in making WordPress sites that looked good and had lots of features. Even though the designs of my clients' websites were great, I quickly saw that they were loading slowly. Bounce rates went up, and users sent in a flood of complaints.

After doing some research, I found that the time it takes for a page to load has a big effect on how happy users are and how well it ranks in search engines. Sites that took too long to load lost visitors and their search engine rankings. Because of this new information, I know it's time to change how I make websites.

I set out on a quest to make all of my clients' websites load faster. Gatsby is a powerful static site generator that I used to improve the look, content, and code of all of the sites. The change was big, and you could see the results almost right away.

As load times went down, users were happier. Users said that the website was easier to use, loaded faster, and took less time to show information. As bounce rates went down and user engagement went up, client satisfaction went up by a lot.

As I helped my clients speed up their websites, their search engine rankings went up in a big way. Since Google liked my Core Web Vitals, my sites did better in organic search and got more views.

After I finished working with a small company, their website saw a huge increase in traffic and sales. Their sales went up by 40% because their new website, which was built with Gatsby, loaded faster. They were thrilled with the increase in sales and praised their customers for the great service they gave them.

Step by Step instructions for setting up Gatsby

Here's how to install Gatsby using Node.js and set up a new Gatsby project using the "gatsby-starter-default" starter:

Step 1: Install Node.js and npm

If you haven't already, download and install Node.js from the official website: Node.js comes with npm (Node Package Manager), which you'll need to install Gatsby and manage dependencies.

Step 2: Install Gatsby CLI

Open your terminal or command prompt. Install the Gatsby Command Line Interface (CLI) globally by running the following command:

npm install -g gatsby-cli

Step 3: Create a new Gatsby project

Once Gatsby CLI is installed, you can create a new Gatsby project using the "gatsby-starter-default" starter. This starter provides a basic setup for your Gatsby project. Run the following command in your terminal:

gatsby new my-gatsby-project

This will create a new directory called "my-gatsby-project" and clone the "gatsby-starter-default" starter into it.

Step 4: Change into the project directory

Change into the newly created project directory: bash cd my-gatsby-project

Step 5: Start the development server

To see your Gatsby website in action during development, start the development server with the following command:

gatsby develop

Step 6: View the website

Once the development server starts, open your web browser and visit http://localhost:8000 to see your new Gatsby website running.

You'll also be able to access the Gatsby GraphQL Playground at http://localhost:8000/___graphql, which allows you to interact with your site's data and explore available queries.

That's it! You now have a new Gatsby project up and running using the "gatsby-starter-default" starter. You can start customizing your website by modifying the source files in the "src" directory.

Best Practises

Proper project structuring and file organization are essential for maintaining a clean and scalable codebase. Here are some best practices for project structuring and file organization:

Folder Structure:

Divide your project into logical folders. Common ones include src for source code, public for static assets, components for reusable UI components, and pages for individual pages in a Gatsby project.

Consider grouping related files together, such as placing all CSS files in a styles folder, all images in an images folder, and all data-related files in a data folder. Use Descriptive Naming:

Choose meaningful and descriptive names for folders and files. This makes it easier for you and your team to understand the purpose of each file and folder.

Avoid Deep Nesting:

Keep your folder structure as shallow as possible. Avoid unnecessary nesting of folders, as it can lead to confusion and longer file paths.

Separation of Concerns:

Follow the principle of Separation of Concerns to keep different types of code separate. For example, keep JavaScript, CSS, and HTML files separate and avoid inline styles. Modularization:

Break your code into smaller, reusable modules or components. This makes it easier to maintain, test, and reuse code across the project.

Organize Imports:

Keep your import statements clean and organized. Group similar imports together, and use a consistent order for imports (e.g., external libraries first, followed by internal modules). Use Index.js Files:

In folders with multiple files, consider using index.js to export and re-export components or utilities, making it easier to import them from outside the folder. Version Control:

Use version control (e.g., Git) to keep track of changes in your project. Commit regularly and provide clear commit messages. Documentation:

Document your code and folder structure. A README file at the root of your project can provide an overview of the project's purpose and instructions on how to run and develop it. Code Linting and Formatting:

Use code linting tools (e.g., ESLint) to enforce consistent code style and catch potential errors. Use code formatting tools (e.g., Prettier) to automatically format your code and keep it consistent.

Avoid Global Variables:

Minimize the use of global variables, as they can lead to unintended side effects and make code harder to maintain.

Keep Build Files Separate:

When building your project for production, keep the generated build files separate from the source code. Typically, this involves having a build or dist folder that contains the optimized output.

By following these best practices, you'll create a well-organized and maintainable codebase, making it easier for you and your team to work on the project over time. Consistency and clarity in the project structure will improve collaboration and reduce the learning curve for new team members.

Tailwind CSS - How to install in a Gatsby project

To install Tailwind CSS in a Gatsby project, you need to follow these steps:

Step 1: Create a new Gatsby project (if you haven't already): If you don't have a Gatsby project set up, you can create one using the Gatsby CLI by running the following command in your terminal:

bash gatsby new my-gatsby-project Step 2: Navigate to the project directory:

bash cd my-gatsby-project Step 3: Install Tailwind CSS and its dependencies:

To use Tailwind CSS in your Gatsby project, you'll need to install it along with its peer dependencies. Tailwind CSS requires PostCSS and Autoprefixer as its dependencies, so you need to install them too.

Run the following command to install Tailwind CSS, PostCSS, and Autoprefixer:

bash npm install tailwindcss postcss autoprefixer Step 4: Create the Tailwind CSS configuration file:

Next, you need to create a configuration file for Tailwind CSS. This file will allow you to customize your project's styles. In the root of your project, create a file named tailwind.config.js and add the following content:

javascript // tailwind.config.js module.exports = { purge: [], darkMode: false, // or 'media' or 'class' theme: { extend: {}, }, variants: { extend: {}, }, plugins: [], }; Step 5: Set up PostCSS configuration:

Gatsby uses PostCSS under the hood, so you need to configure it to use Tailwind CSS. Create a file named postcss.config.js in the root of your project with the following content:

javascript // postcss.config.js module.exports = { plugins: [ require('tailwindcss'), require('autoprefixer'), ], }; Step 6: Import Tailwind CSS into your project:

Now that you've installed Tailwind CSS and set up the configuration, you can import it into your project's CSS file. Create a new CSS file (e.g., styles/tailwind.css) and import Tailwind CSS at the beginning of the file:

css /* styles/tailwind.css */ @import 'tailwindcss/base'; @import 'tailwindcss/components'; @import 'tailwindcss/utilities'; Step 7: Include the CSS file in your Gatsby project:

To include the CSS file in your Gatsby project, you need to import it in your main gatsby-browser.js and gatsby-ssr.js files:

javascript // gatsby-browser.js import './src/styles/tailwind.css'; javascript // gatsby-ssr.js import './src/styles/tailwind.css'; Step 8: Start the development server:

Finally, start the Gatsby development server to see Tailwind CSS in action:

bash gatsby develop Now, Tailwind CSS should be successfully installed and working in your Gatsby project. You can begin using its utility classes to style your components and customize the theme in the tailwind.config.js file.

Using the Gatsby Project can help with performance.

As a web developer, Gatsby has changed the way I think about how to optimise websites. Let me tell you the story of how Gatsby's design magically made websites load faster.

The Problems with Traditional Web Design When I first started out, I used server-side rendering frameworks like WordPress and static Bootstrap sites. Even though I tried my best to optimise the code and assets, websites were still slow and took a long time to load. My nightmares were full of complaints from users and a lot of people leaving the site.

The Great Gatsby: The Static Site of the Future A fellow programmer told me about Gatsby because he thought I would be interested in learning more about it. When I looked into how Gatsby made static sites, I had a sudden realisation. Using Gatsby, sites were made ahead of time in the form of static HTML files. This meant that users got a fully displayed website with very little work from the server. This meant that the website loaded faster and ran better.

Using the Potential of GraphQL Also, it was a big plus that Gatsby's architecture worked so well with GraphQL. I was able to speed things up a lot by using this powerful querying language to get only the data each page needed.

The Pleasures of Code-Splitting Were Looked Into Finding out that Gatsby could break codes was like finding a treasure that had been buried. Gatsby made it easier for my code to load by only loading the small amount of JavaScript that was needed for each page. This clever method cut the time it took to load the page in half, making it much easier for the user to surf the web.

Optimizing a picture: a lesson in beauty Gatsby no longer had a problem with the use of images, which can slow down web pages by a lot. Once the user's device was found, the image optimisation function made the photos smaller and scaled them to fit. To my surprise, I saw that even websites with a lot of images loaded much faster.

One reason SSR is becoming more popular is that Gatsby can do rendering on the server instead of the client. With SSR, crawlers and bots would be able to access the fully rendered content, which would make SEO and social media sharing better. Users were impressed by how easy it was to move from one page to the next with the new page transitions.

Getting the most out of add-ons Because Gatsby has a lot of plugins, you can do anything. With plugins, it's easy to speed up websites and make them work better without having to write a lot of code.

The New Start for Gatsby When I think about it now, I'm glad I took the time to learn about how Gatsby designed his buildings. It changed the way I built websites and made it possible for me to release high-performance sites that both clients and end users loved.

Gatsby has been a big help to me in my pursuit of speed optimisation. It has allowed me to make user experiences that are beautifully designed and run very quickly. Gatsby's architecture has changed how I think about and build websites, and I will always be grateful for that.

Website performance is very important when it comes to both search engine optimisation and the user experience. It's more important to give visitors a useful and enjoyable browsing experience than to impress them with fancy design. "Prateeksha Web Design" is known for making sites that leave a lasting impression. This is because of how quickly the Internet has grown.

Read more blogs

Prateeksha Web Design

Prateeksha Web Design is pleased to welcome you to the premier website design firm in Mumbai. Creative and dedicated, we focus on developing unique digital experiences for companies to use in their success on the web.


  • Terms & Conditions
  • Privacy Policies
  • Career
  • feedback


Andheri Industrial Estate, Near Janki Centre, Veera Desai Road, Andheri (West), Mumbai 400053. India.
Whatsapp: +91 98212 12676
Old Cherry Point Rd New Bern, Nc 28560

© 2023 Prateeksha Web Design. All rights reserved | Privacy Policy | Terms of Use