Can Hugo generate one site for multiple domains?

I’m trying to figure out whether Hugo can do what I want before I invest a lot of time.

With LAMP I’ve been serving the same script output on several domain names, so they’re mirrors of one site. The client sees the correct domain name on each page, agreeing with the URL, but there’s only one script - the other domains have individual virtual hosts but the content for each is just a symlink to the one they’re mirroring.

From what I can tell about Hugo so far, a domain name has to be hardcoded in the configuration site-wide? Does this mean I would have to make a separate copy of the site for,,, etc.? Or maybe there’s a way to make it pick up the SNI value?

Yes, you can take advantage of the --baseURL="" switch on the hugo command when you generate the site before deploying it to hosting.

1 Like

So the best alternative is one copy of the whole site for, another whole copy for, and so on?

Can anyone confirm there is really no way to make a pointer to another site yet have the correct domain name (whichever the client connected to) appear on the pages?

No, same site folder, default config in the config.toml, and just generate the different sites by assigning a different --baseURL when you run hugo to generate.

This is the zsh function I use to generate and publish one of my sites via zsh:

Then, for instance my config:

… and referencing assets using relURL like so:

As I read Rick Cogley’s answer it requires several Hugo generations to create the html-documents needed for the multi-site setup, that George Clinton needs advice for.
In my experience, however, it’s possible to generate multiple sites/domains in just one Hugo generation. Please take my website - - with 8 sibling-sites as a proof of that.
All 9 websites in this cluster are generated in one go. This is made possible by placing each site in its own section-folder, which also becomes the destination-folder for the generated html-documents. The rest is done quite easily with Nginx.
This solution makes use of just a slash as the baseURL in config.yaml. The separation of domains is achieved by using absolute urls in all links to specific documents - with use of domain-info from each documents front matter. This also opens for lists with content from multiple domains.


Interesting @JLKM, thanks. I’ll have to look into your method.

If I’m understanding correctly, nothing unique really needs to be done with Hugo. You can have Hugo build the site, using relative URLs throughout, meaning no domain name. Then, on the web server side (Apache or Nginx for example), you can serve the content via different domains, how you see fit. This is assuming that the content and design is EXACTLY the same.

If it’s just the design that you want the same, that could be put in a theme that each site shares.


Thanks for answers everyone!

I’m not totally clear on how it works but going to experiment today.

On re-reading the intro stuff I realized that one need not be concerned about duplicating the md-to-html generation, it’s fast and cheap. (I was coming from the live-script perspective where it’s better to run one instance.)

To clarify, what I’ve been doing is putting a home-page link on each page with the URL text being the ‘SERVER_NAME’ from apache, which picks up the SNI value from the request. I think browsers display relative links that way but didn’t want to rely on browser defaults. Anyway it’s moot.

Hugo looks about right for a blog

1 Like