Multihost trouble

I am trying to set up a multi host site and am struggling to have assets loaded on both local webservers (:1313 and :1314). To illustrate this I created a small test case in using exampleSite content of the hugo-scroll theme.

Using hugo server both local webservers are created just fine:

Web Server is available at http://localhost:1314/ (bind address en
Web Server is available at http://localhost:1313/ (bind address de

Unfortunately only for one of the sites assets like the CSS are loaded correctly. I might be mistaken, but what stood out to me was

<link rel="stylesheet" href="http://localhost:1314/[...]

in the preview running on http://localhost:1313/ (note the different referenced port: 1314 vs 1313). Not sure if this it the issue though…

Am I missing anything obvious?

Thanks a lot in advance.

❯ hugo env
hugo v0.126.2-8f3d902ce51512931f5759e9279d93e346c9e649+extended linux/amd64 BuildDate=2024-05-30T15:19:22Z VendorInfo=snap:0.126.2

without your site setup I’m just guessing.

do you have the portnumber in your baseUrl

  • if so remove it (keep the trainling /)
  • if not you might want to share your repo so one can lookup


1 Like

Thanks @jmooring for your diagnosis and improvements!

1 Like

Following all these improvements, I’m still seeing an issue I can’t seem to be able to resolve.

I introduced use urls.AbsLangURL if hugo.IsMultihost · zjedi/hugo-scroll@33337a6 · GitHub in zjedi/hugo-scroll. To show a link to the other configured language sites, this logic is used:

        {{ if hugo.IsMultihost }}
	    <a class='btn-lang' href='{{ "" | urls.AbsLangURL }}'>{{ $lang_title }}</a>
        {{ else }}
	    <a class='btn-lang' href='{{ . | relURL }}'>{{ $lang_title }}</a>
        {{ end }}

It works great in a local hugo server setting, but fails when I create the production site.

Does anyone know what the issue is here?

What does that mean?

When I generate the site, the link to the English site in public/de/index.html points to the baseURL of the de site.

I updated the example repo to reflect this.

I haven’t had a chance to dig into the details yet, but please add this to your site config:

defaultContentLanguage: de

You need to do this to avoid

For the language switcher on the home page…

{{ range site.Sites }}
  {{ $lang_title := or .Language.LanguageName (.Language.Lang | strings.ToUpper) }}
  {{ if eq . $.Site }}
    {{ if $.Site.Params.show_current_lang }}
      <span class='btn-lang active'>{{ $lang_title }}</span>
    {{ end }}
  {{ else }}
    <a class='btn-lang' href='{{ .Home.Permalink }}'>{{ $lang_title }}</a>
  {{ end }}
{{ end }}
1 Like

Wow amazing, this looks like it’s working! <3

I’ll make sure this ends up in hugo-scroll attributed to you.

1 Like

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