问题排查

如果您在使用模板编辑器时遇到了问题,请查看下面是否列出了您的问题。

常见问题

问题:加载页面失败

页面正重定向到不受支持的 URL

如果您的店面包含将用户重定向到未与您的商店相连接的 URL 的代码,请在使用模板编辑器时确认此重定向已被禁用。

例如,为了根据买家所在的地点将他们定向到不同的 Shopify 商店,此类型的重定向可能会被添加到店面上。此类型的重定向代码可能存在于您的模板或安装的应用中。

为了确保您的重定向不会影响编辑器体验,请在您模板的 JavaScript 代码中将 window.location.href = 替换为 window.parent.location.href =。如果无法执行此操作,则在使用模板编辑器时在 JavaScript 中使用对 window.Shopify.designMode 变量的引用来禁用此重定向。当店面加载到编辑器中时,此变量将设置为 true;如果未加载,此变量将设置为 false

由于出现错误,页面无法加载

由于多种原因,页面无法加载到模板编辑器中。常见问题包括以下内容:

  • 网络连接问题

  • 模板中的 Liquid 代码无效

如果您已验证这些问题不会导致错误,请尝试通过导航到模板编辑器中的模板操作 > 预览模板来访问您的在线商店。如果页面无法加载,您可以联系 Shopify 支持以获取有关您店面的帮助。

出现 HTML 错误

在模板编辑器中更改模板设置时,您可能会在编辑器中看到“发现 HTML 错误”警告消息:

当您的模板代码中存在语法错误时,会显示此错误消息。若要解决此问题,您可以检查错误消息中引用的 Liquid 文件中的代码。在上方的示例中,此代码为 slideshow.liquid

查找模板代码中的问题

  1. 点击链接到错误消息的 .liquid 分区文件。这会将您定向到编辑 HTML/CSS 页面,并且文件将在代码编辑器中打开。

  2. 仔细查看文件中的代码,并尝试找到无效的 HTML 或 Liquid。代码编辑器将用红色显示潜在的语法错误。常见问题如下:

    • 额外的结束 HTML 标记,例如,结束 </div> 没有对应的开始 <div>

    • 额外的开始 HTML 标记,例如,开始 <div> 没有对应的结束 </div>

    • HTML 标记格式错误,例如,<div class="my-class" 缺少 >

    • Liquid 代码格式错误

    • 包含的模板代码片段文件中的 HTML 已损坏

  3. 找到问题后,更正您的模板文件中的代码。

  4. 点击保存

  5. 点击自定义以返回模板编辑器,并确认错误消息已消失。

其他解决方案

如果您无法按照前面的步骤解决问题,请考虑以下选项:

  • 回退到旧版模板文件

  • 从模板商店中安装新版模板并切换到该版本

  • 了解您的模板提供的支持类型

Shopify商户官网原文详情:

Troubleshooting

If you are experiencing issues with your theme editor, then check if your issue appears below.

Common issues

Issue: Failed to load the page

Page is redirecting to an unsupported URL

If your storefront includes code that redirects users to URLs that are not connected to your shop, then verify that the redirect has been disabled when you visit the theme editor.

For example, this type of redirect may be added to a storefront in order to direct buyers to different Shopify stores depending on their location. This type of redirect code could exist in either your theme or an app that you installed.

To ensure your redirect does not interfere with the editor experience, replace window.location.href = with window.parent.location.href = in your theme’s JavaScript code. If that is not possible, use a reference to the window.Shopify.designMode variable in JavaScript to disable the redirect when you visit the theme editor. This variable is set to true when the storefront is loaded in the editor and false when it is not.

Page failed to load due to an error

A page can fail to load in the theme editor for many reasons. Common issues include the following:

  • network connection issues

  • invalid Liquid code in your theme

If you have verified that these issues are not causing the error, then try visiting your online store by navigating to Theme actions > Preview theme in the theme editor. If the page fails to load, then you can contact Shopify support for help with your storefront.

HTML error found

When making changes to your theme settings in the theme editor, you might see an 'HTML error found' warning message in the editor:




This error message appears when a syntax error is found in your theme code. To resolve the problem, you can examine the code in the Liquid file that is referenced in the error message. In the example above, this would be the slideshow.liquid.

Finding the problem in your theme code

  1. Click on the .liquid section file that is linked to in the error message. This will take you to the Edit HTML/CSS page, and the file will open in the code editor.

  2. Look through the code in the file and try to find invalid HTML or Liquid. The code editor will show potential syntax errors in red. Common problems include the following:

    • Extra closing HTML tags, for example, a closing </div> without an opening <div>

    • Extra unclosed HTML tags, for example, an opening <div> without a closing </div>

    • Malformed HTML tags, for example, <div class="my-class" without a >

    • Malformed Liquid code

    • Broken HTML in an included theme snippet file

  3. Once you've found the problem, correct the code in your theme file.

  4. Click Save.

  5. Click Customize to return to the theme editor, and confirm that the error message is gone.

Other solutions

If you are unable to resolve the problem by following the previous steps, then consider the following options:

  • Roll back to an older version of your theme file

  • Install and switch to new version of the theme from the Theme Store

  • Find out what kind of support is available for your theme

文章内容来源:Shopify商户官方网站


(本文内容根据网络资料整理,出于传递更多信息之目的,不代表连连国际赞同其观点和立场)