Gatsby is a super fast and fantastic React-based open-source framework for creating websites and apps.
In this context, we shall look into how to install Gatsby on your Ubuntu 20.04 LTS.
In order to install Gatsby successfully, you need to follow the below steps.
1. Update system
Before performing any Software Installation, it is always recommended to keep the system updated. So to do this, simply execute the below command:
$ sudo apt update
2. Check Node , NPM and Git version
Here, You must verify that your system is running up-to-date Node.js, NPM, and Git packages. Here is how to do it with the below commands:
$ node --version
$ npm --version
$ git --version
If none of the above packages are installed on your system then you should first install them. Use the below command:
$ sudo apt install node
$ sudo apt install npm
$ sudo apt install git
3. Install Gatsby.js CLI
Unlike other packages which might be installed in a specific project directory. Gatsby will be installed globally only. A local or directory-specific node package can be installed without sudo, but a global package can only be installed using sudo.
Now run the below command:
$ sudo npm install -g gatsby-cli
Once Gatsby.js is installed, we are ready to start creating new static websites.
Start by creating a new directory with the below command:
$ mkdir gatsbySite
Then change the directory with the below command:
$ cd /gatsbySite
Now to create your first site, simply run the following command and you are good to go:
$ gatsby new
Here, Gatsby will ask you a few questions like what's your site name, your specific folder name of your website, and some plugin details.
After answering all of them, your site will be created.
To initiate a local server that will show you your website locally, simply execute the command:
$ npm run develop
Now you can access your local site on http://localhost:8000/.
This article covers how to install Gatsby static site generators on Ubuntu 20.04 Linux system. In fact, Gatsby fetches all the data, renders the entire website into static HTML, CSS, JS files with the data available at that time. As it generates the static files, Gatsby applications can be deployed in anywhere.