I have read docs but didn’t get about public dir.
So why hugo create it?
Why we should remove this everytime?
Should I push it to GitHub or not?
The public
folder contains all HTML files generated by Hugo. If you run hugo server
, Hugo will serve this pages with the build-in server.
Should I push it to Github? It depends. If you are just working on the source code of your site or you write a new article then you only push the raw markdown files, templates etc. Usually you don’t add generated files to a version control system since you can reproduce them at any time. Furthermore, they would just take space on disk.
If you want to deploy the generated HTML files with Github pages on the gh-pages
branch, then you should read this tutorial.