Xzya / hugo-bootstrap

This is a simple Hugo theme using Bootstrap v4.
MIT License
76 stars 51 forks source link

[Question] How works links to static resources? #23

Closed iGormilhit closed 5 years ago

iGormilhit commented 5 years ago

In the layouts files, I've seen that to build an URL to get the css or another static resource, the code is {{ .SiteBaseURL }}css/style.css, and that the file is in static/css/style.css.

So, I have a static folder in my hugo directory, with a sub folder img that contains my logo.svg. And in the layouts/partials/brand.html, I have this code: <img src="{{ .Site.BaseURL }}img/logo.svg" ..., which works fine with hugo server.

However, when trying to deploy through Netlify, the URL to style.css and logo.svg get a 404 error. The path are https://[my-domain]/css/style.css or https://[my-domain]/img/logo.svg.

So, I'm wondering how the resolution to the static directory works.

iGormilhit commented 5 years ago

Ok, I got it, sorry for the noise.

I was checking the build version on a Netlify preview, and so the base URL isn't the right one. I've change my layouts/partials/brand.html code to this: <img src="{{ .Site.BaseURL | relURL }}img/logo.svg" ..., and the preview is now working as I expect.