简体   繁体   English

在shopify中将css和js文件调出到新页面

[英]Call out css and js files to a new page in shopify

I purchased a template of an HTML landing page online and I'm trying to integrate it in my current theme in Shopify. 我在线购买了HTML登陆页面的模板,并试图将其集成到Shopify中的当前主题中。 The landing page contains html, css and js that I have to integrate. 登陆页面包含我必须集成的html,css和js。 I read a previous thread that explained that I have to upload the css and js files to the "Assets" folder and add those lines to the "theme.liquid" file : 我读了一个先前的线程,它解释说我必须将css和js文件上载到“资产”文件夹,并将这些行添加到“ theme.liquid”文件中:

{{ 'script.js.liquid' | asset_url | script_tag }}

{{ 'style.css.liquid' | asset_url | stylesheet_tag }}

Then I created a page template and copy pasted the html code, but no styling comes out only plain html. 然后,我创建了一个页面模板,并复制粘贴了html代码,但是仅纯HTML不会出现任何样式。 I was wondering what I was doing wrong. 我想知道我做错了什么。 Do I have to add some code to call out the css and js files into the newly created page or just adding the above line of codes in the "theme.liquid file is sufficient? 我是否必须添加一些代码以将css和js文件调出到新创建的页面中,或者仅在“ theme.liquid文件中添加以上代码行就足够了?

Thank you in advance for your help. 预先感谢您的帮助。

Try removing the .liquid suffix when trying to load a stylesheets or scripts for a given template: 尝试为给定模板加载样式表或脚本时,请尝试删除.liquid后缀:

{{ 'script.js' | asset_url | script_tag }}
{{ 'style.css' | asset_url | stylesheet_tag }}

If the stylesheet is a SCSS stylesheet, you'll need to have .scss. 如果样式表是SCSS样式表,则需要具有.scss. added to the stylesheet identity to ensure it get's compiled to CSS. 已添加到样式表标识中,以确保将其编译为CSS。

{{ 'style.scss.css' | asset_url | stylesheet_tag }}

If it still doesn't load, try clearing cache after saving/pushing the changes to the template or viewing from a incognito browser tab while not logged in as admin. 如果仍然无法加载,请在将更改保存/推送到模板后或尝试以隐身浏览器标签查看(而不以管理员身份登录)后,尝试清除缓存。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM