Access Background Image From SCSS File

Access Background Image From SCSS File

I’m trying to access an image from static/images from an SCSS File.

       a::before {
          content: "";
          position: absolute;
          top: .25em;
          left: 0;
          width: .5rem;
          height: .5rem;
          background: url(/images/marker.svg) no-repeat 50%;
        }

I have the image in the static/images file. When baseURL is root and when testing using the huge server it works fine. But when I publish my site its baseURL becomes /something. It’s not at the root. That path changes so i need it to be generic. Is there a way to have that URL in an SCSS file be relative to baseURL like other urls in layout files?

Show your project so we can see how the URLs are constructed.

Let me get a GitRepo together to share.

Basically though the url needs to be /something/images/marker.svg not /images/marker.svg but I can’t hardcode that because it could change. I change it in baseURL.

this is the repo here

How about this?

1 Like

This worked. Thank you so much! I missed that in the docs.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.