Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a reason public is included in gatsby's gitignore?

Tags:

gatsby

I want to add a title and description meta tag for my index.html page in my public folder to improve SEO but gatsby has index.html in its gitignore file. Is it ok for me to remove index.html from gitignore without breaking anything? Is there a different way to update index.html without having it reset every time I push through git?

like image 353
dev_el Avatar asked May 15 '20 10:05

dev_el


People also ask

What are SRC pages in Gatsby?

“src” is a convention for “source code”. /api JavaScript and TypeScript files under src/api become functions automatically with paths based on their file name. Check out the functions guide for more detail. /pages Components under src/pages become pages automatically with paths based on their file name.

What is static folder in Gatsby?

The static folder is useful as a workaround for a number of less common cases: You need a file with a specific name in the build output, such as manifest. webmanifest . You have thousands of images and need to dynamically reference their paths. You want to include a small script like pace.


Video Answer


1 Answers

The public folder is created by Gatsby on each build and if you add anything to the public folder, it will be overriden when the build runs next time

As per the Gatsby documentation

/public Automatically generated. The output of the build process will be exposed inside this folder. Should be added to the .gitignore file if not added already.

In order to add page metadata such as description and title, Gatsby recommends to use react-helment

According to documentation

Adding metadata to pages, such as page title, meta description, alt text and structured data using JSON-LD, helps search engines understand your content and when to show your pages in search results.

A common way to add metadata to pages is to add react-helmet components (together with the Gatsby React Helmet plugin for SSR support) to your page components.

like image 103
Shubham Khatri Avatar answered Dec 09 '22 23:12

Shubham Khatri