Jump to content

Import external css/less

Recommended Posts

I have two different sites to handle two languages. ( currics.com and currics.se )

Is it possible for them to share common css somehow?

I have tried having a common less file on another server and importing it via less, but it doesn't seem to work

This at the top of my custom css:

@import url(https://static.currics.com/css/generic.less);

just gives me an error: Cannot read property 'href' of undefined.

Not sure about if I will end up in Cross-origin problems later but the error comes before that, in the editor.

Shouldn't this be possible?

Link to comment
  • 9 months later...
On 11/9/2020 at 5:42 AM, dearnaomichan said:

I am having the same error when I try to import a Google font in my css. Did you ever find a solution or figure out why this was happening?

You can use link rel & add to Code Injection Header

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Link to comment
  • 2 weeks later...

Took a while until I got around to this.
I tried injecting the following:

<link rel="stylesheet/less" type="text/css" href="https://static.currics.com/css/generic.less" crossorigin="anonymous" />
<script src="//cdn.jsdelivr.net/npm/less" ></script>

I had already configured CORS on the server as well.

This sort of works. Everything looks fine when visiting the page ... BUT ... that less file isn't parsed when I'm editing my site. So depending on how custom stuff you have it might not be a good idea.

For me it didn't work out. I still think it should be possible to do via an import statement. Wierd that squarespace doesn't allow it.

Edited by kristofferdarj
Edit: A clarification that it doesn't work in backend.
Link to comment
  • 1 year later...

@tuanphan Hey, I have a similar QS on the topic, but with nuance that I'd like to host that CSS on a different hosting because the original place where this CSS hosted is unbelievably slow, so it takes lots of time before the webpage finally loads. Can I host a CSS on SS somehow? What could be the workaround here?

Link to comment
On 12/4/2021 at 8:40 PM, Vit said:

@tuanphan Hey, I have a similar QS on the topic, but with nuance that I'd like to host that CSS on a different hosting because the original place where this CSS hosted is unbelievably slow, so it takes lots of time before the webpage finally loads. Can I host a CSS on SS somehow? What could be the workaround here?

Upload CSS to your site, follow this guide https://support.squarespace.com/hc/en-us/articles/205813928-Uploading-and-managing-files

Suppose, The uploaded file is style01.css

To delcare CSS to your site, add this code into Code Injection > Header

<link rel="stylesheet" href="/s/style01.css">

 

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Link to comment
  • 4 weeks later...

Is there a way to directly link a .css file on an external URL ? Either via code injection or something

The css editor window in Squarespace is so small, I'd rather work in Visual Studio Code and sync to my ftp to make css changes.

Uploading to directly Squarespace each time doesn't work well as I want to be able to edit and sync in real time which Visual Studio Code allows me to do.

Link to comment
9 hours ago, leaflotus said:

The css editor window in Squarespace is so small, I'd rather work in Visual Studio Code and sync to my ftp to make css changes.

You can store your CSS file on Squarespace and sync with FTP if you are using Developer Mode on a Squarespace 7.0 site. It isn’t an option on Squarespace 7.1. 

For an alternative option that will allow you to automatically sync your CSS file with the Custom CSS panel, see the Squarespace Code Connector plugin in the Squarewebsites store

About me: I've been a SQSP User for 18 yrs. I was invited to join the Circle when it launched in 2016. I have been a Circle Leader since 2017. I don't work for Squarespace. I value honesty, transparency, diversity and good design ♥.
Work: I founded and run SF.DIGITAL, building Squarespace Extensions to supercharge your commerce website. 
Content: Views and opinions are my own. Links in my posts may refer to SF.DIGITAL products or may be affiliate links.
Forum advice is free. You can thank me by clicking one of the feedback emojis below. Coffee is optional.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.