如何使用Shopify和Liquid在我的主页上显示所有产品?

问题描述:

我可以在index.liquid页面(主页)上使用一个简单的Liquid标记片段来显示我拥有的所有产品,并使每个图像都链接到相应产品的信息页面吗?

Is there a simple snippet of Liquid markup I can use on my index.liquid page (home page) to display all of the products that I have and make each of those images a link to the respective product's information page?

大多数主题在其主页上显示一个集合.使用该功能,不要添加代码.

Most themes display a collection on their home page. Go with that functionality, don't add code.

要使您的主页集合包含商店中的所有产品,请使其成为具有条件(例如产品价格> 0)的智能集合.

For your home page collection to include all products in your store, make it a smart collection with a condition such as Product Price > 0.

如果您的商店中有50多种产品,则可以通过在模板/index.liquid文件中添加Liquid标签来向您的主页添加分页.为了获得有关如何在Shopify主题中进行分页的灵感,请查看您的template/collection.liquid文件.

If you have more than 50 products in your shop, you can add pagination to your home page by adding Liquid tags to your templates/index.liquid file. For inspiration on how pagination is done in a Shopify theme, look into your templates/collection.liquid file.

您的主题可能会对您的主页上显示的主页集合中的多少产品有一定的限制.在这种情况下,您可以在templates/index.liquid文件中找到类似以下代码的代码:

There is possibly some limit imposed by your theme on how many products from your homepage collection are shown on your home page. If that's the case, you'll find code that looks like this in your templates/index.liquid file:

{% for product in collections.frontpage.products limit: 12 %}

删除限制属性.