如果您在使用模板編輯器時(shí)遇到了問(wèn)題,請(qǐng)查看下面是否列出了您的問(wèn)題。
問(wèn)題排查
如果您在使用模板編輯器時(shí)遇到了問(wèn)題,請(qǐng)查看下面是否列出了您的問(wèn)題。
問(wèn)題:加載頁(yè)面失敗
頁(yè)面正到不受支持的 URL
如果您的店面包含將用戶重定向到未與您的商店相連接的 URL 的代碼,請(qǐng)?jiān)谑褂媚0寰庉嬈鲿r(shí)確認(rèn)此重定向已被禁用。
例如,為了根據(jù)買(mǎi)家所在的地點(diǎn)將他們定向到不同的 商店,此類型的重定向可能會(huì)被添加到店面上。此類型的重定向代碼可能存在于您的模板或安裝的應(yīng)用中。
為了確保您的重定向不會(huì)影響編輯器體驗(yàn),請(qǐng)?jiān)谀0宓?JavaScript 代碼中將 window.location.href =
替換為 window.parent.location.href =
。如果無(wú)法執(zhí)行此操作,則在使用模板編輯器時(shí)在 JavaScript 中使用對(duì) window.Shofy.designMode
變量的引用來(lái)禁用此重定向。當(dāng)?shù)昝婕虞d到編輯器中時(shí),此變量將設(shè)置為 true
;如果未加載,此變量將設(shè)置為 false
。
由于出現(xiàn)錯(cuò)誤,頁(yè)面無(wú)法加載
由于多種原因,頁(yè)面無(wú)法加載到模板編輯器中。常見(jiàn)問(wèn)題包括以下內(nèi)容:
網(wǎng)絡(luò)連接問(wèn)題
模板中的 Liquid 代碼無(wú)效
如果您已驗(yàn)證這些問(wèn)題不會(huì)導(dǎo)致錯(cuò)誤,請(qǐng)嘗試通過(guò)導(dǎo)航到模板編輯器中的模板操作 > 預(yù)覽模板來(lái)訪問(wèn)您的在線商店。如果頁(yè)面無(wú)法加載,您可以聯(lián)系 Shopify 支持以獲取有關(guān)您店面的幫助。
出現(xiàn) HTML 錯(cuò)誤
在模板編輯器中更改模板設(shè)置時(shí),您可能會(huì)在編輯器中看到“發(fā)現(xiàn) HTML 錯(cuò)誤”警告消息:
當(dāng)您的模板代碼中存在語(yǔ)法錯(cuò)誤時(shí),會(huì)顯示此錯(cuò)誤消息。若要解決此問(wèn)題,您可以檢查錯(cuò)誤消息中引用的 Liquid 文件中的代碼。在上方的示例中,此代碼為 slideshow.liquid
。
查找模板代碼中的問(wèn)題
點(diǎn)擊鏈接到錯(cuò)誤消息的 .liquid
分區(qū)文件。這會(huì)將您定向到編輯 HTML/CSS 頁(yè)面,并且文件將在代碼編輯器中打開(kāi)。
仔細(xì)查看文件中的代碼,并嘗試找到無(wú)效的 HTML 或 Liquid。代碼編輯器將用紅色顯示潛在的語(yǔ)法錯(cuò)誤。常見(jiàn)問(wèn)題如下:
額外的結(jié)束 HTML 標(biāo)記,例如,結(jié)束 </div>
沒(méi)有對(duì)應(yīng)的開(kāi)始 <div>
額外的開(kāi)始 HTML 標(biāo)記,例如,開(kāi)始 <div>
沒(méi)有對(duì)應(yīng)的結(jié)束 </div>
HTML 標(biāo)記格式錯(cuò)誤,例如,<div
缺少 >
Liquid 代碼格式錯(cuò)誤
包含的模板代碼片段文件中的 HTML 已損壞
找到問(wèn)題后,更正您的模板文件中的代碼。
點(diǎn)擊保存。
點(diǎn)擊自定義以返回模板編輯器,并確認(rèn)錯(cuò)誤消息已消失。
其他解決方案
如果您無(wú)法按照前面的步驟解決問(wèn)題,請(qǐng)考慮以下選項(xiàng):
回退到舊版模板文件
從模板商店中安裝新版模板并切換到該版本
了解您的模板提供的支持類型
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:
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 . 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
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.
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
without a >
Malformed Liquid code
Broken HTML in an included theme snippet file
Once you've found the problem, correct the code in your theme file.
Click Save.
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
特別聲明:以上文章內(nèi)容僅代表作者本人觀點(diǎn),不代表ESG跨境電商觀點(diǎn)或立場(chǎng)。如有關(guān)于作品內(nèi)容、版權(quán)或其它問(wèn)題請(qǐng)于作品發(fā)表后的30日內(nèi)與ESG跨境電商聯(lián)系。