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 https://github.com/dholbach/scroll-multi 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 127.0.0.1) en
Web Server is available at http://localhost:1313/ (bind address 127.0.0.1) 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
GOOS="linux"
GOARCH="amd64"
GOVERSION="go1.22.3"
github.com/sass/libsass="3.6.5"
github.com/webmproject/libwebp="v1.3.2"
github.com/sass/dart-sass/protocol="2.7.0"
github.com/sass/dart-sass/compiler="1.77.3"
github.com/sass/dart-sass/implementation="1.77.3"
irkode
June 1, 2024, 12:33pm
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
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?
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 https://github.com/gohugoio/hugo/issues/12564 .
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
system
Closed
June 5, 2024, 5:44pm
12
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.