Hugo server - serve multiple hugo projects in different web paths of same server

I have several separate hugo sites (deployed as ज्योतिषे विश्वासटिप्पन्यः | +परिचयः संस्कारे विश्वासटिप्पन्यः | +संस्कारः वेदे विश्वासटिप्पन्यः | +वेदाः). While developing on my computer, I need hugo server to continuously build all of them and host them on a single server, giving me paths such as http://localhost:1313/saMskAra/ and http://localhost:1313/vedAH/. (Currently, if I run hugo server --renderToDisk in for each project, I get paths on different ports such as http://localhost:1313/saMskAra/ and http://localhost:40531/vedAH/ ). How do I accomplish this?

You have multiple hugo instances running. Every hugo command will create a server on a port. If you want to stop the instance you have to type CTRL+C and it will shut down and free the port. But from the way you describe your problem there is a process running already when you start a new one. In that case Hugo will select a different port.

Also check out the CLI documentation, there are options to run the server on a port you specify:

Hi @davidsneighbour - Thanks, I fully understand everything you said there already.

Question is about how to serve multiple hugo builds on the same development server (with “hugo server”). In the example provided, I want to serve the sites named “vedAs” and “saMskAra” on the same server, as is the case in the production environment (reason being that javascript in one site needs content from the other to properly render the page). It may be that this feature is not supported- in which case I’d appreciate guidence on how to request it (I bet I’m not the only one serving multiple hugo sites on different paths a and b in the same xyz.github.io domain - with xyz.github.io/b/u/ linking to xyz.github.io/a/u/).

The above isn’t physically possible (as in: No framework could support the above).

1 Like

@bep Currently, hugo server --renderToDisk builds and serves one single hugo site (the one in the current directory). What if one could pass it n source directories - hugo server --renderToDisk --sources=/a/b/c,/a/y/z and expect it to build them and serve them on HTTP at different paths (specified by the config files in the respective directories)? Would such a generalization be too hard?

Since you’re the first asking the above question, you need first to talk about the “why is this useful?”.

Sure, let me make a case for it (please let me know if any point needs further support).

Proposition 1: It is useful to have multiple hugo builds for different paths on the same server.

Supports for Proposition 1:

Proposition 2: Despite having distinct Hugo builds for distinct HTTP paths on the same server, it is a common use-case to refer (via HTML links or JS loading) to content across paths.

Proposition 3 (which motivates the feature request): One would want to test the cross-path references referred to in Proposition 2 in a development environment.

Isn’t this something for a batchjob (Powershell, Bash, etc.) where you may call several hugo server commands with different path and port configurations?

@realB12 - For the development environment to properly simulate production environment, it is essential that the baseUrl and hence the port be the same for all these paths - so hugo server would have to build various “sites” (for various paths) with that goal in mind.

Maybe I do not understand your requirements. Sorry for that.

A developer environment will often cut some corners to make it faster/simpler. Heck, Hugo’s server doesn’t even do HTTPS (which we should fix).

I agree that what you want could be useful, but the complexity of it means that it will probably not be added to Hugo anytime soon.