如何在 Symfony 2.0 中使用元标签 [英] How to use Meta Tags with Symfony 2.0

查看:35
本文介绍了如何在 Symfony 2.0 中使用元标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道如何在我网站的所有页面中添加 Meta 标签?

I don't know how to add Meta Tags in all the pages of my website?

推荐答案

正确,您可以将元标记放在站点的基本布局中.对于更复杂的愿望,您可以将它们放入一个块中,如果需要,您可以在特定模板中覆盖它们.

Correct, you can put your meta tags in the base layout of your site. For more complex wishes you can put them into a block and if you want you can overwrite them in your specific templates.

有关更多信息,请查看 Symfony2 文档创建和使用模板.

For more information take a look at the Symfony2 documentation Creating and using Templates.

示例:

在您的基本模板中,例如app/Resources/view 中的 base.html.twig

in your base template, e.g. base.html.twig in app/Resources/view

{% block meta_title %}Default meta title{% endblock %}

在您的模板中:

{% extends '::base.html.twig' %}

{% block meta_title %}{{ page.title }}{% endblock %}

这篇关于如何在 Symfony 2.0 中使用元标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆