Reputation: 872
I don't know how to add Meta Tags in all the pages of my website?
Upvotes: 3
Views: 6832
Reputation: 872
@F481,so I find a good solution,personnaly I do like that :
{% block meta %}
{% if (page.description) %}
<meta name="description" content="{{ page.description }}">
{% endif %}
{% if (page.keywords) %}
<meta name="keywords" content="{{ page.keywords }}">
{% endif %}
{% endblock %}
And I store my keywords and description for each page in DB.
Upvotes: 7
Reputation: 990
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.
For more information take a look at the Symfony2 documentation Creating and using Templates.
Example:
in your base template, e.g. base.html.twig in app/Resources/view
{% block meta_title %}Default meta title{% endblock %}
in your template:
{% extends '::base.html.twig' %}
{% block meta_title %}{{ page.title }}{% endblock %}
Upvotes: 9