`hugo` command from another folder

I want to build my public files from another folder. Is there a way to specify an absolute path where the site is located?

For example, if I’m on the folder /home/mike/ and my site is located at /home/mike/mysite.com/ , I’d like to build my site without changing the working directory. (I’m writing a script to automatically build and deploy multiple sites). I know this can be accomplished with a simple cd command, but I’d like to know if there is a parameter that we could pass to the hugo command.

I tried with hugo -c /home/mike/mysite.com/content -d /home/mike/mysite.com/public but it doesn’t work.

the -s flag is what tells hugo where the site files are located as per the docs: https://gohugo.io/getting-started/usage/#the-hugo-command


When in doubt, type

hugo -h

Or see https://gohugo.io/commands/hugo/