> For the complete documentation index, see [llms.txt](https://flask-yushu.gitbook.io/yushu/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://flask-yushu.gitbook.io/yushu/7.-jing-tai-wen-jian-mo-ban-xiao-xi-shan-xian-yu-jinja2/7.2-mo-ban-wen-jian-de-wei-zhi-yu-xiu-gai-fang-an-x264.md).

# 7.2 模板文件的位置与修改方案\_x264

## 1.默认位置

模板文件默认的位置是根目录（这里的根目录口径同上一节）下的templates，然后再下面建立html文件。

编写视图函数，返回值使用Flask的render\_template方法，第一个参数传html页面名称，后面的参数可以穿要渲染的数据对key-value。key为这组数据名，value为数据对象

![image.png](https://upload-images.jianshu.io/upload_images/7220971-3ae85ad1149ba53d.png?imageMogr2/auto-orient/strip|imageView2/2/w/1240)

## 2.修改默认位置

如果要修改模板默认位置的话，可以在app或者蓝图实例化的时候，传入template\_floder关键字参数

```
web = Blueprint('web', __name__,template_folder='')
```

```
app = Flask(__name__,template_folder='')
```

* 不建议将视图和静态资源建立在蓝图下面，因为他们可能属于多个蓝图。
