npm init gatsby
Start by going to the directory with
and start the local development server with:
npm run develop
Gatsby will start a hot-reloading development environment accessible by default at http://localhost:8000. Usually,
npm run develop command can be used to build your site into development mode without any issues. But, sometimes errors happen and didn’t work for me right away, I get this error returned:
This error tells that
"trackingId" can’t be set as empty…
Invalid plugin options for "gatsby-plugin-google-analytics": - "trackingId" is not allowed to be emptySetting up Google Analytics
gatsby-plugin-google-analytics to track site activity and provide insights into how users access your website.
- Sign in to your Google Analytics account.
- Click Admin.
- Select an account from the menu in the ACCOUNT column.
- Select a property from the menu in the PROPERTY column.
- Under Property, click Tracking Info > Tracking Code. Your Tracking ID is displayed at the top of the page.
Once you get
trackingId go to your gatsby-config.js file and replace it:
npm run develop and Gatsby will start a development environment accessible by default at http://localhost:8000 mine looked like this:
Now you’re ready to make changes to your site by editing the home page in
src/pages/index.js, saved changes will live reload in the browser.
This was a quick start, for intermediate to advanced developers. For a gentler intro to Gatsby and more details check this tutorial.
Add more features
Install and configure additional plugins to quickly add additional functionality to your site.