Gitignore of Hugo project to optimise netlify builds


I have a few questions regarding Netlify and Hugo, specifically about optimizing build times and improving integration.

  1. What is the recommended .gitignore configuration for a Hugo project hosted on Netlify?

  2. Regarding the “public” folder: Should it be included in the .gitignore file, or is it beneficial to keep it in version control if the repository already contains existing files in the “public” folder?

  3. Concerning the “node_modules” directory: Should it be included or excluded from the .gitignore file when hosting a Hugo site on Netlify?

  4. What about the “resources” folder: Is it advisable to include or exclude it from the .gitignore when hosting on Netlify?

Thank you in advance for your assistance.

This is more of a coding/development question than Netlify, which is not what these forums are for. But to give a quick answer, you can refer to: Hrishikesh-K/tejal (

resources is debatable. Committing it would make the builds faster if you’re using a lot of Hugo’s image processing (if not, then please don’t commit it). If you don’t wish to commit it, but still want faster builds, you can use something like: Hugo Cache Resources | Netlify Integrations (it’s not officially maintained by us, so any issues/questions related to it would be for that plugin’s dev, not for Netlify)

1 Like