How to override multilingual multihost baseURLs with environment config?

Is it possible to override baseURL definitions by using an environment config? I found that for our site, it is not working. In a recent patch (unmerged), I had to comment out the main baseURLs in order for our preview build to work.

If it isn’t possible, I could create an issue for it and we might put development effort into it. What do you think?

Full source of our site.

The source code seems to work fine even with the baseURLs activated.

Please provide more information about the issue. Also, please refer requesting help.

If you apply the patch and uncomment the baseURLs from the main config and build with

hugo -e preview

there will be no media, css, js, fonts directories in public. This means the relative URLs to assets will be broken.

Getting this to work would be the last missing piece in the puzzle that was discussed in the issue Multilingual, multihost site with relativeURLs enabled has broken links when viewing without a server · Issue #7805 · gohugoio/hugo · GitHub

This multilingual multi-host example:
https://discourse.gohugo.io/t/crafting-and-configuring-a-serverless-site/48029

Has this configuration directory structure:

config/
├── _default/
│   └── hugo.toml
├── development/
│   └── hugo.toml
├── production/
│   └── hugo.toml
└── serverless/
    └── hugo.toml

The default configuration is single-host. Multi-host is only enabled for the “development” and “production” environments.

If you were to enable multi-host in the default configuration by setting a baseURL under each language key, there’s no way to override that in another environment… you cannot remove a key once set.

1 Like

Thanks. Would it be problematic to allow overriding keys?

Once a key is set you can override it.

But you can’t unset it.

Once you set the baseURL under a language key to any value, the site becomes multi-host. You cannot undo that.

Ok, then the solution is to provide baseURL definitions in separate environments. I updated my patch accordingly. A bit of config sprawl, but it works at least.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.