[SOLVED] Multilingual Site not returning correct URL

I’m building an english site and a spanish site. While the english site is fine, the images and fonts do not show in the spanish site.

{
"baseurl" : "https://mysite.com/",
"publishdir": "build",
"contentDir" : "content",
"canonifyURLs": "true",
"defaultContentLanguage" : "en",
"title" : "My Site",
"permalinks" : {
},
"languages": {
	"en": {
		"baseurl" : "https://mysite.com/",
		"languageCode" : "en-us",
		"weight" : 1
	},
	"es": {
		"baseurl" : "https://mysite.com/es",
		"languageCode": "es-ES",
		"weight": 2
	}
},
"staticDir": [
	"static"
]
}

The images and fonts I want are in the static folder and being called as a CSS background image. The HTML is inside the markdown file. But the URL returned in the console log error is http://localhost:1314/img/… instead of http://localhost:1314/es/img

You may want to check my theme repo. I used to have exactly the same issue, and implemented absolute paths in my “url” CSS code. E.g.:


I did the same for the fonts, e.g.:

Thank you! However I’m already doing this too.

Or do you mean that I should do this:

background: url('/Users/Me/Desktop/MySite/static/img/banner-tablet.jpg') center center repeat;

Probably not, but can’t be sure here. Please show us your code.

If you provide baseURL per language it should be different domains. You obviously don’t want that, so start by removing the baseURL from each language.

1 Like

Didn’t notice that :blush:

Thanks for all the input! It works now simply when I do this

background-image: url('../img/tablet.svg'),
linear-gradient(to top, #38bdff, #1a8cff);

where I add ‘…’ relative paths to the URL :sweat_smile: I don’t really understand why, though.