Jump to content

Meta tags for Twitter Cards


Recommended Posts

Does anyone have any experience to adding meta tags for Twitter Cards when it comes to the Pages application?

I was looking at the includeMeta template within core->global->global to potential add some form of if statement that if on the pages application, grab the author and various other data that is tied to the current page (ie an article).

Any help would be appreciate as I couldn't find much when searching.

Link to comment
Share on other sites

Just now, Ibragim Pupkevich said:

You mean to make your board bages displyaed properly in Twitter when shared by someone?


Or you mean embedding tweets in your board content items (posts, comments etc.)?

In regards to board pages being displayed in Twitter when shared.

More specifically I'm looking at it in regards to articles on my site, but other pages are applicable I guess.

Link to comment
Share on other sites

For the time being I've hacked together this in the includeMeta template which at least gives me the title and description but obviously I could do with it being a little cleaner and include author data and possibly image.

<meta name="twitter:card" content="summary" />
<meta name="twitter:site" content="@RespawnGG" />

{{foreach \IPS\Output::i()->metaTags as $name => $content}}
	{{if $name != 'title'}}
		{{if is_array( $content ) }}
			{{foreach $content as $_value }}
				{{if $name === 'og:title'}} <meta name="twitter:title" content="{$_value}"> {{endif}}
				{{if $name === 'og:description'}} <meta name="twitter:description" content="{$_value}"> {{endif}}
			{{if $name === 'og:title'}} <meta name="twitter:title" content="{$content}"> {{endif}}
			{{if $name === 'og:description'}} <meta name="twitter:description" content="{$content}"> {{endif}}
Link to comment
Share on other sites

  • 2 months later...
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:site" content="@cheersngears">
<meta name="twitter:image" content="{$this->settings['meta_imagesrc']}" />
<if test="metatags:|:is_array( $metaTags ) AND count( $metaTags )">
	<foreach loop="metaTags:$metaTags as $tag => $id">
		<foreach loop="metaTagsInner:$metaTags[ $tag ] as $content">
		<if test="ogCaveman:|:stristr( $tag, 'og:' )">
			<meta property="{$tag}" content="{$content}" />                        
		<else />
			<meta name="{$tag}" content="{$content}" />
		<if test="hasIdentifier:|:$tag == 'identifier-url'">
			<meta property="og:url" content="{$content}" />
		<if test="hasDescription:|:$tag == 'description'">
			<meta property="og:description" content="{$content}" >
                        <meta name="twitter:description" content="{$content}" />                        
                <if test="hasDescription:|:$tag == 'title'">
			<meta property="og:title" content="{$content}" >
                        <meta name="twitter:title" content="{$content}" />                        
<meta property="og:image" content="{$this->settings['meta_imagesrc']}" />


Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...