osprey icon indicating copy to clipboard operation
osprey copied to clipboard

Unable to resolve "styles.main.css"

Open TheHackerDev opened this issue 8 years ago • 2 comments

When using the baseURL of "/" (as recommended in a number of places, including here), the main.css file is attempting to be loaded from http://styles/main.css, which obviously doesn't resolve anywhere.

Here's the relevant line of code: https://github.com/tomanistor/osprey/blob/master/layouts/partials/header.html#L74

I fixed this by changing it to the following:

<link rel="stylesheet" href="{{ .Site.BaseURL }}styles/{{ if .Site.Params.cacheBustCSS }}{{ index .Site.Data.styles.hash "main.css" }}{{ else }}main.css{{ end }}" type="text/css">

I simply removed the leading / before styles/, so it would load from [baseUrl]/styles/main.css.

Cheers, Aaron (insp3ctre)

TheHackerDev avatar Sep 14 '17 18:09 TheHackerDev

Just FYI the same issue happened on the blog.html page. I changed the same element of the line as follows:

<div class="col-xs-12"><h3><a href="{{ .Site.BaseURL }}blog/">View All</a></h3></div>

Cheers, Aaron (insp3ctre)

TheHackerDev avatar Sep 22 '17 20:09 TheHackerDev

This can also be solved with:

{{ if .Site.Params.cacheBustCSS }}
    <link rel="stylesheet" href="{{ (index .Site.Data.cachedAssets "main.css") | absURL }}">
{{ else }}
    <link rel="stylesheet" href="{{ "/styles/main.css" | absURL }}">
{{ end }}

Similar issue with the og:image which could be:

<meta property="og:image" content="{{ .Site.Params.opengraphImage | absURL }}">

And with the favicon, which could be:

<link rel="icon" type="image/png" sizes="16x16" href="{{ "/images/logo/favicon.ico" | absURL }}">

However setting the baseURL to / actually uncovers additional problems. For example, og:url is equal to .Site.BaseURL which it seems should be a full url with domain/protocol, but in this case would be just a /.

crgeary avatar Oct 13 '17 17:10 crgeary