x_ml
May 30, 2018, 1:10pm
1
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.:
@font-face {
font-family: 'FontAwesome';
src: url('/fonts/fontawesome-webfont.eot?v=4.7.0');
src: url('/fonts/fontawesome-webfont.eot?#iefix&v=4.7.0') format('embedded-opentype'), url('/fonts/fontawesome-webfont.woff2?v=4.7.0') format('woff2'), url('/fonts/fontawesome-webfont.woff?v=4.7.0') format('woff'), url('/fonts/fontawesome-webfont.ttf?v=4.7.0') format('truetype'), url('/fonts/fontawesome-webfont.svg?v=4.7.0#fontawesomeregular') format('svg');
font-weight: normal;
font-style: normal;
}
x_ml
May 30, 2018, 3:50pm
3
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.
bep
May 30, 2018, 5:03pm
5
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
x_ml
May 31, 2018, 10:11am
7
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 I don’t really understand why, though.