首页 > 解决方案 > 如何将 css 文件添加到 Squarespace 开发者模式

问题描述

我添加了index.css内部样式,并将其包含在template.conf

{
  "name": "Wright",
  "author": "Squarespace, Inc.",
  "layouts": {
    "default": {
      "name": "Default",
      "regions": [
        "site"
      ]
    }
  },
  "stylesheets": [
    "index.css"
  ],
  etc...
}

我从文档中看到样式表将被编译成site.css

stylesheets

List of your stylesheet. Stylesheets will be compiled into site.css following the ordering here.

NOTE: If you add a file named reset.css to the /styles/ folder it will automatically get added to the top of the site.css file. It should not be listed in the "stylesheets" variable in template.conf.

site.css这个文件在哪里?它是如何调用的site.region

目前,我无法以这种方式加载自定义 css 文件。

标签: csssquarespace

解决方案


该文件site.css是所有 Squarespace 的默认样式以及stylesheets: [ ... ]您在问题中添加的任何样式的编译结果输出。

每当您(或 Squarespace 的)样式表发生更改时,它都会自动为您创建。您没有对它的直接写入权限,并且不会在您的模板中看到它。

因此,如果您实际上已按照问题中所述完成(将文件添加到文件中/styles并将其添加到template.conf文件中),并且您随后通过 Git 更新了模板(请注意,SFTP 存在错误,可能不会更新您的文件) ,之后当用户加载网站时,您的 CSS 将包含在 site.css 中。

要回答您的最后一个问题,site.css 文件不是通过任何区域文件直接加载的。也就是说,如果你在代码中搜索它,你不会找到它。相反,它是作为 的一部分加载的{squarespace-headers},您可以在模板文件中找到它,无论是在.region文件中还是在.block文件中。


推荐阅读