Do I need to build the public folder if I host on Netlify?

My previous usage of Hugo was to both store the repo on Github and to host it with Github Pages. Now I’m trying to move the hosting to Netlify.

One bit of confusion I have - it looks like people are simply pushing new posts to their Github Repo, and Netlify is basically watching for changes and will then run a Hugo build on their own server, which updates the site. So there is no need to run ‘hugo’ on my own local dev environment?

Am I close?

The common use for Netlify sites is:

  • Run hugo server locally to edit and preview
  • When happy, commit your source (not /public – which fits naturally into .gitignore)
  • Netlify runs hugo and publishes your site

That matches what I’ve seen in a few places, yet this tutorial indicates that I should specify the public folder in netlify.toml…

OK, now I understand. Netlify needs to know where to pick up the generated content. You can set this in the publish config variable in the Netlify console, but also in a netlify.toml file that you can commit to your repo:

1 Like

yeah, that’s how I have it configured - and Netlify built the site even without a ‘public’ folder in my repo. Not yet displaying correctly but I don’t think the DNS has finished propagating.

UPDATE: now working!

1 Like

quick follow up here? Can I do the other way around and have netlify simply pick up my \public folder? I am merging two hugo theme’s and i suspect a regular hugo build won’t work. Technically I could update the command as well I guess, but I wanted to understand if there is a way to do simply pick up the public folder.

@nipunarora this question might be better taken over to the netlify forums. I suspect for your situation, if you’re building two sites using Hugo and wanting one to be published in a sub directory of the other, the solution might be to build the public folder on your development machine and then use the netlify API to deploy the site rather than having netlify build and deploy the site.