You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Shopify:Recipes博客标签列表页面无内容输出问题求助

问题分析与解决方案

核心问题

你的代码存在两个关键语法错误,导致无法正确遍历博客标签:

  • 博客引用错误:Liquid中访问指定博客时,字符串形式的博客名称/handle必须用英文引号包裹。你写的blogs[recipes]里的recipes未加引号,Liquid会将其视为变量而非'Recipes'博客的标识,因此无法定位到目标博客。
  • 中文引号语法错误:代码里的id=”blog-tags”使用了中文双引号,这会导致HTML属性解析异常(虽不是标签不显示的直接原因,但属于必须修正的语法问题)。

修正后的代码

方式一:使用字符串索引(匹配博客名称)

<div id="blog-tags">
    <!-- Loops over all the tags used in Recipes blog -->
    {% for tag in blogs['Recipes'].tags %}
        <h2>{{ tag }}</h2>
    {% endfor %}
</div>

方式二:使用handle索引(更稳妥,匹配博客URL标识)

如果你的'Recipes'博客URL是你的店铺域名/blogs/recipes,说明它的handle是recipes,可以直接用点语法访问:

<div id="blog-tags">
    <!-- Loops over all the tags used in Recipes blog -->
    {% for tag in blogs.recipes.tags %}
        <h2>{{ tag }}</h2>
    {% endfor %}
</div>

额外验证

如果修正后仍无内容,可先在模板中添加调试代码确认博客是否存在:

{{ blogs.recipes.title }}  <!-- 输出'Recipes'则说明博客定位正确 -->

内容的提问来源于stack exchange,提问作者Dan Hennion

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.03 05:15:32