|
1 | | -.. This reStructured text file has been automatically generated, do not change. |
2 | | -.. Source: https://github.com/TYPO3/typo3/blob/main/typo3/sysext/fluid/Classes/ViewHelpers/Page/MetaViewHelper.php |
3 | | -
|
4 | | -:edit-on-github-link: https://github.com/TYPO3/typo3/edit/main/typo3/sysext/fluid/Classes/ViewHelpers/Page/MetaViewHelper.php |
5 | 1 | :navigation-title: page.meta |
6 | 2 |
|
7 | 3 | .. include:: /Includes.rst.txt |
|
12 | 8 | Page.meta ViewHelper `<f:page.meta>` |
13 | 9 | ==================================== |
14 | 10 |
|
| 11 | +.. versionadded:: 14.0 |
| 12 | + |
| 13 | +.. typo3:viewhelper:: page.meta |
| 14 | + :source: /Global.json |
| 15 | + :display: tags, gitHubLink |
| 16 | + :noindex: |
| 17 | + |
| 18 | +.. contents:: Table of contents |
| 19 | + |
| 20 | +The Fluid ViewHelper :html:`<f:page.meta>` allows meta tags to be defined |
| 21 | +directly within Fluid templates by leveraging TYPO3's MetaTagManager API. |
| 22 | + |
| 23 | +This allows frontend rendering logic—such as Extbase plugins, Fluid-based |
| 24 | +content elements, or site package templates—to control meta tags (for |
| 25 | +example descriptions, OpenGraph data, and social media cards) directly in |
| 26 | +Fluid templates, without requiring custom PHP logic. |
| 27 | + |
| 28 | +Meta tags can be defined and managed directly in Fluid templates, reducing |
| 29 | +or eliminating the need for additional TypoScript configuration in many |
| 30 | +common scenarios. |
| 31 | + |
| 32 | +.. _typo3-fluid-page-meta-usage-examples: |
| 33 | + |
| 34 | +Using the `<f:page.meta>` ViewHelper |
| 35 | +=================================== |
| 36 | + |
| 37 | +The following examples demonstrate common use cases for the |
| 38 | +:html:`<f:page.meta>` ViewHelper in frontend Fluid templates. They show how |
| 39 | +meta tags can be defined, extended, and replaced directly in Fluid while |
| 40 | +integrating with TYPO3's MetaTagManager system. |
| 41 | + |
| 42 | +.. _typo3-fluid-page-meta-example-detail-view: |
| 43 | + |
| 44 | +Set meta tags in a detail view template |
| 45 | +-------------------------------------- |
| 46 | + |
| 47 | +Meta tags can be defined directly in a Fluid template, for example in a |
| 48 | +detail view that renders a single domain object. |
| 49 | + |
| 50 | +.. code-block:: html |
| 51 | + :caption: EXT:my_extension/Resources/Private/Templates/Item/Show.html |
| 52 | + |
| 53 | + <f:page.meta property="description">{item.description}</f:page.meta> |
| 54 | + <f:page.meta property="og:title">{item.title}</f:page.meta> |
| 55 | + <f:page.meta property="og:type">article</f:page.meta> |
| 56 | + |
| 57 | + <h1>{item.title}</h1> |
| 58 | + <p>{item.description}</p> |
| 59 | + |
| 60 | + |
| 61 | +.. _typo3-fluid-page-meta-example-opengraph: |
| 62 | + |
| 63 | +Define OpenGraph and Twitter / X Card meta tags |
| 64 | +----------------------------------------------- |
| 65 | + |
| 66 | +OpenGraph and Twitter / X Card meta tags can be used to control how pages |
| 67 | +are displayed when shared on social media platforms. |
| 68 | + |
| 69 | +.. code-block:: html |
| 70 | + |
| 71 | + <f:page.meta property="og:title">My Article Title</f:page.meta> |
| 72 | + <f:page.meta property="og:description">Article description</f:page.meta> |
| 73 | + <f:page.meta property="twitter:card"> |
| 74 | + summary_large_image |
| 75 | + </f:page.meta> |
| 76 | + |
| 77 | + |
| 78 | +.. _typo3-fluid-page-meta-example-subproperties: |
| 79 | + |
| 80 | +Use sub-properties for complex meta tags |
| 81 | +---------------------------------------- |
| 82 | + |
| 83 | +Some meta tags, such as image-related tags, support additional |
| 84 | +sub-properties like dimensions or alternative text. |
| 85 | + |
| 86 | +.. code-block:: html |
| 87 | + |
| 88 | + <f:page.meta property="og:image" |
| 89 | + subProperties="{width: 1200, height: 630, |
| 90 | + alt: 'Article image'}"> |
| 91 | + {item.image.url} |
| 92 | + </f:page.meta> |
| 93 | + |
| 94 | + |
| 95 | +.. _typo3-fluid-page-meta-example-custom-types: |
| 96 | + |
| 97 | +Define custom meta tag types |
| 98 | +---------------------------- |
| 99 | + |
| 100 | +Custom meta tags can be defined by explicitly specifying the meta tag type |
| 101 | +attribute. |
| 102 | + |
| 103 | +.. code-block:: html |
| 104 | + |
| 105 | + <f:page.meta property="author" type="name">John Doe</f:page.meta> |
| 106 | + <f:page.meta property="robots" type="name"> |
| 107 | + index, follow |
| 108 | + </f:page.meta> |
| 109 | + |
| 110 | + |
| 111 | +.. _typo3-fluid-page-meta-example-replace: |
| 112 | + |
| 113 | +Replace existing meta tags |
| 114 | +-------------------------- |
| 115 | + |
| 116 | +Existing meta tags with the same property can be replaced explicitly when |
| 117 | +required. |
| 118 | + |
| 119 | +.. code-block:: html |
| 120 | + |
| 121 | + <f:page.meta property="description" replace="true"> |
| 122 | + Override any existing description |
| 123 | + </f:page.meta> |
| 124 | + |
| 125 | + |
| 126 | +All examples shown above integrate with TYPO3's MetaTagManager system and |
| 127 | +respect configured meta tag managers, priorities, and rendering rules. |
| 128 | +This enables a template-centric approach to managing SEO-relevant meta |
| 129 | +data that reflects the rendered content accurately. |
| 130 | + |
| 131 | +.. _typo3-fluid-page-meta-arguments: |
| 132 | + |
| 133 | +Arguments of the `<f:page.meta>` ViewHelper |
| 134 | +=========================================== |
| 135 | + |
| 136 | +.. include:: /_Includes/_ArbitraryArguments.rst.txt |
| 137 | + |
15 | 138 | .. typo3:viewhelper:: page.meta |
16 | | - :source: ../../Global.json |
| 139 | + :source: /Global.json |
| 140 | + :display: arguments-only |
0 commit comments