23 Oct 2019
How to build your first Gatsby project.
6 Quickest steps and prerequisites to get started with Gatsby
1 .To have Node.js installed in the system.
6 Steps to get started with Gatsby
1. Install the Gatsby CLI.
npm install -g gatsby-cli
2. Create a new site.
gatsby new site-name
3. Change directories into the site folder.
4. Start the development server.
5. Create a production build.
6. Serve the production build locally.
By default, project will start running on localhost:8000
- Note: The command to run the project in development mode is npm run develop.
- Gatsby Project Files:
- gatsby-browser : We can add customized jquery code.
- gatsby-config : you can lots of pretty amazing plugins from https://www.gatsbyjs.org/plugins/ . and Command To install the plugin is npm install –save plugin-name . So, We gatsby-config file will consist of plugin options.
- gatsby-node : Gatsby gives plugins and site builders many APIs for controlling your site. If your plugin performs async operations (disk I/O, database access, calling remote APIs, etc.) you must either return a promise or use the callback passed to the 3rd argument. Gatsby needs to know when plugins are finished as some APIs, to work correctly, require the previous APIs to be complete first.
- gatsby-ssr : Implement any of these APIs by exporting them from a file named gatsby-ssr.js in the root of your project.
- There are several folders in src folder
Pages : you can add your pages in this folder.
Images : You can add your image files to this folder.
Components : You can create each reusable components to this folder.