PHPackages                             heimrichhannot/contao-head-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. heimrichhannot/contao-head-bundle

ActiveContao-bundle[Utility &amp; Helpers](/categories/utility)

heimrichhannot/contao-head-bundle
=================================

This module contains enhancements for the contao frontend page &lt;head&gt; region.

1.14.2(5mo ago)26.7k↓50%1[1 issues](https://github.com/heimrichhannot/contao-head-bundle/issues)5LGPL-3.0-or-laterPHPPHP ^7.4 || ^8.0CI failing

Since Sep 12Pushed 5mo ago4 watchersCompare

[ Source](https://github.com/heimrichhannot/contao-head-bundle)[ Packagist](https://packagist.org/packages/heimrichhannot/contao-head-bundle)[ RSS](/packages/heimrichhannot-contao-head-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (15)Versions (58)Used By (5)

Contao Head bundle
==================

[](#contao-head-bundle)

[![](https://camo.githubusercontent.com/88645b0f5a2b492e560ab4d2afe702a78649bd1785d533464f9a16889f184238/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6865696d7269636868616e6e6f742f636f6e74616f2d686561642d62756e646c652e737667)](https://packagist.org/packages/heimrichhannot/contao-head-bundle)[![](https://camo.githubusercontent.com/73920fa0c3560e9f18a53e9180a44e973426966c627901f58e0767b99b6aec15/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6865696d7269636868616e6e6f742f636f6e74616f2d686561642d62756e646c652e737667)](https://packagist.org/packages/heimrichhannot/contao-head-bundle)

This bundle enhances the handling of html `` section tags. It provides services to update head tags dynamically from your code.

Features
--------

[](#features)

- Provide a nice api to set head tags like meta, title, base, link
- Provide additional json-ld schema data
- Sets important meta tags like og:title, og:description, og:url and twitter:card out of the box
- Allow setting open graph and twitter fallback image on root page
- Allow setting twitter author per root page
- Backport canonical url option from contao 4.13 for contao 4.9+
- Backport json-ld support for contao 4.9+

Usage
-----

[](#usage)

### Setup

[](#setup)

1. Install with composer
2. Update your database
3. Set following config variables (if you don't need the legacy implementation)

    ```
    huh_head:
      use_contao_head: true
      use_contao_variables: true
    ```
4. Optional: Set fallback image and twitter author in root page(s)

### Add additional meta tags

[](#add-additional-meta-tags)

In your root page, you can activate to add fallback image (og:image and twitter:image) and twitter username (twitter:site) meta tags to you web page.

[![Screenshot Meta Data Settings](docs%2Fimg%2Fscreenshot_backend_meta_data.png)](docs%2Fimg%2Fscreenshot_backend_meta_data.png)

### Add additional schema.org data

[](#add-additional-schemaorg-data)

In your root page, you can activate to add additional structured data to you web page. Following schema.org types are available:

- @Organization
- @WebSite
- @WebPage
- @BreadcrumbList

[![Screenshot Structured Data Settings](docs%2Fimg%2Fscreenshot_backend_structured_data.png)](docs%2Fimg%2Fscreenshot_backend_structured_data.png)

### Set json-ld in your templates

[](#set-json-ld-in-your-templates)

This bundle backports the methods of contao 4.12+ to contao 4.9+. So usage is the same as in the contao core.

#### Twig templates

[](#twig-templates)

```
{% do add_schema_org({
    '@type': 'NewsArticle',
    'headline': newsHeadline|striptags,
    'datePublished': datetime|date('Y-m-d\TH:i:sP'),
}) %}
```

#### PHP templates

[](#php-templates)

```
