# 主题参考
使用 Liquid 模板语言开发 Shopify 主题的指南。
## Liquid 模板
### 语法基础
**对象 (输出):**
liquid
{{ product.title }}
{{ product.price | money }}
{{ customer.email }}
**标签 (逻辑):**
liquid
{% if product.available %}
{% else %}
Sold Out
{% endif %}
{% for product in collection.products %}
{{ product.title }}
{% endfor %}
{% case product.type %}
{% when 'Clothing' %}
Apparel
{% when 'Shoes' %}
Footwear
{% else %}
Other
{% endcase %}
**过滤器 (转换):**
liquid
{{ product.title | upcase }}
{{ product.price | money }}
{{ product.description | strip_html | truncate: 100 }}
{{ product.image | img_url: 'medium' }}
{{ 'now' | date: '%B %d, %Y' }}
### 常用对象
**Product (产品):**
liquid
{{ product.id }}
{{ product.title }}
{{ product.handle }}
{{ product.description }}
{{ product.price }}
{{ product.compare_at_price }}
{{ product.available }}
{{ product.type }}
{{ product.vendor }}
{{ product.tags }}
{{ product.images }}
{{ product.variants }}
{{ product.featured_image }}
{{ product.url }}
**Collection (集合):**
liquid
{{ collection.title }}
{{ collection.handle }}
{{ collection.description }}
{{ collection.products }}
{{ collection.products_count }}
{{ collection.image }}
{{ collection.url }}
**Cart (购物车):**
liquid
{{ cart.item_count }}
{{ cart.total_price }}
{{ cart.items }}
{{ cart.note }}
{{ cart.attributes }}
**Customer (客户):**
liquid
{{ customer.email }}
{{ customer.first_name }}
{{ customer.last_name }}
{{ customer.orders_count }}
{{ customer.total_spent }}
{{ customer.addresses }}
{{ customer.default_address }}
**Shop (商店):**
liquid
{{ shop.name }}
{{ shop.email }}
{{ shop.domain }}
{{ shop.currency }}
{{ shop.money_format }}
{{ shop.enabled_payment_types }}
### 常用过滤器
**字符串:**
- `upcase`, `downcase`, `capitalize`
- `strip_html`, `strip_newlines`
- `truncate: 100`, `truncatewords: 20`
- `replace: 'old', 'new'`
**数字:**
- `money` - 格式化货币
- `round`, `ceil`, `floor`
- `times`, `divided_by`, `plus`, `minus`
**数组:**
- `join: ', '`
- `first`, `last`
- `size`
- `map: 'property'`
- `where: 'property', 'value'`
**URL:**
- `img_url: 'size'` - 图片 URL
- `url_for_type`, `url_for_vendor`
- `link_to`, `link_to_type`
**日期:**
- `date: '%B %d, %Y'`
## 主题架构
### 目录结构
theme/
├── assets/ # CSS, J