Skip to content

Instantly share code, notes, and snippets.

@benjaminrau
Created August 25, 2014 07:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save benjaminrau/af7d667a44f8cbae4f2e to your computer and use it in GitHub Desktop.
Save benjaminrau/af7d667a44f8cbae4f2e to your computer and use it in GitHub Desktop.
This section defines all metatags which are used to have defined in a website. It also contains the most relevant OG-Tags for facebook. It can also be used as an example how to read FAL images related to a page record. Here it is used as og:image
<div xmlns:v="http://typo3.org/ns/FluidTYPO3/Vhs/ViewHelpers"
xmlns:f="http://typo3.org/ns/fluid/ViewHelpers">
<f:section name="MetaTags">
{v:resource.record.fal(record: page, field: 'media', table: 'pages') -> v:iterator.extract(key: 'uid') -> v:iterator.first() -> v:var.set(name: 'pageMedia')}
<v:page.header.meta name="keywords" content="{page.keywords}" />
<v:page.header.meta name="description" content="{page.description}" />
<v:page.header.meta name="og:title" content="{page.title}" />
<v:page.header.meta name="og:type" content="article" />
<v:page.header.meta name="og:url" content="{v:page.absoluteUrl()}" />
<v:page.header.meta name="og:description" content="{page.description}" />
<f:if condition="{pageMedia}">
<v:page.header.meta name="og:image" content="{f:uri.image(src: pageMedia, treatIdAsReference: 1, maxHeight: 1024, maxWidth: 1024) -> v:format.prepend(add: '{v:page.siteUrl() -> v:format.substring(length: \'-1\')}')}" />
</f:if>
<v:page.header.meta name="apple-mobile-web-app-capable" content="yes" />
</f:section>
</div>
@lucasinteractive
Copy link

The helper var.set and v.page.siteUrl are deprecated right now. To make the script working with the current version of vhs (2.1.x) change

v:var.set(name: 'pageMedia')
to
v:variable.set(name: 'pageMedia')

and

v:page.siteUrl()
to
v:site.url()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment