---
title: 引用和继承
---
## 引用模板片段
对于如下两个模板文件:
```
// 文件:color.liquid
color: '{{ color }}' shape: '{{ shape }}'
// 文件:theme.liquid
{% assign shape = 'circle' %}
{% include 'color' %}
{% include 'color' with 'red' %}
{% include 'color', color: 'yellow', shape: 'square' %}
```
输出为:
```
color: '' shape: 'circle'
color: 'red' shape: 'circle'
color: 'yellow' shape: 'square'
```
{% note tip ".liquid" 文件扩展名 %}
如果设置了 `extname: ".liquid"` 选项,就可以省略 layout, render 和 include 里面文件名的 ".liquid" 后缀。详情请参考 extname 选项。
{% endnote %}
## 布局模板(模板继承)
对于如下两个模板文件:
```
// 文件:default-layout.liquid
Header
{% block content %}My default content{% endblock %}
Footer
// 文件:page.liquid
{% layout "default-layout" %}
{% block content %}My page content{% endblock %}
```
渲染 `page.liquid` 将会输出:
```
Header
My page content
Footer
```
{% note tip Block %}