Gatsby is a super fast and fantastic node-based static site generator. It is a multipurpose generator and has powerful tools that skyrock a website. I am using Ubuntu 20.04 LTS, and I will show you how to install Gatsby on your Ubuntu system. All instructions are Ubuntu-specific. It is important not to use these commands on Debian as they will result in a system break due to different dependency requirements.
You must verify that your system is running up-to-date Node.js, NPM, and Git packages. Here is how to do it.
$ node --version
$ npm --version
$ git --version
If none of the above packages are installed on your system then you should first install them. Here is how you will do it:
$ sudo apt install node
$ sudo apt install npm
$ sudo apt install git
Check with your package manager if there is a need for any PPA.
Next is to 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.
Let’s do it:
$ sudo npm install -g gatsby-cli
It took about six minutes to install a few hundred packages. Gatsby is pretty big regarding dependency requirements.
Once Gatsby.js is installed, we are ready to start creating new static websites.
First, you will need to create a new driectory.
$ mkdir gatsbySite
then change the directory as shown below:
$ cd /gatsbySite.
Now it is simple to create your first site, run the following command and you are good to go. Refer the screenshot:
$ gatsby new
At this point, Gatsby will ask you a few questions like what’s your site name, your specific folder name of your website, and some plugin details as shown below.
You simply need to answer all of them and the site will be created.
With the following command, you will initiate a local server that will show you your website locally.
$ npm run develop
Now you can access your local site on http://localhost:8000/
In this guide, we examined how to install Gatsby static site generators on Ubuntu 20.04. The above instructions are valid only for Ubuntu distribution. Now you have installed a super-fast static site generator on your Linux system. It will be a pleasure to learn about your installation experience. Have your say!
Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications including CCNA RS, SCP, and ACE. As an IT engineer and technical author, he writes for various websites.