You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|`add_head_tag(name, value)`| Add all kinds of head tag. Meta tag names must be prefixed with `meta_`, for example `meta_description` or `meta_og:title`. |
79
+
|`add_head_meta_tag(name, value)`| Shorthand for meta tags. The function adds the `meta_` prefix automatically. |
80
+
|`add_head_tags(array)`| Add multiple tags at once. Pass as key => value or a `AbstractHeadTag` object. Meta tags must be prefixed with meta when passed as key. |
81
+
|`get_head_news_tags(model, figure)`| Create an array of tags for news models. The function automatically adds og:title, og:description, og:url and og:image tags. Pass a figure to override default news article image. |
82
+
83
+
The `value` argument can be a string, `null` or a Contao `Figure`. If a `Figure` is passed, its image source is used as the tag content.
84
+
45
85
## Integration
46
86
Use head bundle api set in your code.
47
87
@@ -51,11 +91,12 @@ To set base, title, meta and link tags, use the `HtmlHeadTagManager` service:
51
91
52
92
```php
53
93
use HeimrichHannot\HeadBundle\HeadTag\BaseTag;
94
+
use HeimrichHannot\HeadBundle\HeadTag\LinkTag;
54
95
use HeimrichHannot\HeadBundle\HeadTag\MetaTag;
55
-
use HeimrichHannot\HeadBundle\HeadTag\TitleTag;
56
96
use HeimrichHannot\HeadBundle\HeadTag\Meta\CharsetMetaTag;
57
97
use HeimrichHannot\HeadBundle\HeadTag\Meta\HttpEquivMetaTag;
58
98
use HeimrichHannot\HeadBundle\HeadTag\Meta\PropertyMetaTag;
99
+
use HeimrichHannot\HeadBundle\HeadTag\TitleTag;
59
100
use HeimrichHannot\HeadBundle\Manager\HtmlHeadTagManager;
The bundle provides Twig functions to add head tags from Twig templates:
135
-
136
-
```twig
137
-
{# Set the title tag #}
138
-
{% do add_head_tag('title', 'Hello World') %}
139
-
140
-
{# Set the base tag #}
141
-
{% do add_head_tag('base', 'https://example.org') %}
142
-
143
-
{# Add meta tags #}
144
-
{% do add_head_meta_tag('description', 'Lorem ipsum!') %}
145
-
{% do add_head_meta_tag('og:title', 'Hello World') %}
146
-
{% do add_head_meta_tag('twitter:image', figure) %}
147
-
```
148
-
149
-
Use `add_head_tag(name, value)` for generic head tags supported by the `HeadTagFactory`. Meta tag names must be prefixed with `meta_`, for example `meta_description` or `meta_og:title`.
150
-
151
-
Use `add_head_meta_tag(name, value)` as shorthand for meta tags. The function adds the `meta_` prefix automatically.
152
-
153
-
The `value` argument can be a string, `null` or a Contao `Figure`. If a `Figure` is passed, its image source is used as the tag content.
154
-
155
170
## Template output
156
171
157
172
Be sure, `huh_head.use_contao_head` and/or `huh_head.use_contao_variables` are not set to true.
0 commit comments