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

Viewed 1753

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?

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.

Related