• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Meta Description

akia

Well-known member
#1
I'm trying to set up the twitter card meta tags but I'm having problems with this one:

<meta name="twitter:description" content="">

I've tried:

<xen:if is="{$pageDescription.content} AND !{$pageDescription.skipmeta} AND !{$head.description}"><meta name="twitter:description" content="{xen:string wordTrim, {xen:helper stripHtml, {xen:raw $pageDescription.content}}, 200}"></xen:if>

and

<meta name="twitter:description" content="{xen:raw $pageDescription.content}">

but neither will output the description when I check the page source. Can anyone help with what I should use?
 

Jake Bunce

XenForo moderator
Staff member
#4
There is no PAGECONTENT template. Do you mean PAGE_CONTAINER? Just add it to the head:

Code:
<!DOCTYPE html>
<html id="XenForo" lang="{$visitorLanguage.language_code}" dir="{$visitorLanguage.text_direction}" class="Public {xen:if {$visitor.user_id}, 'LoggedIn', 'LoggedOut'} {xen:if {$sidebar}, 'Sidebar', 'NoSidebar'}" xmlns:fb="http://www.facebook.com/2008/fbml">
<head>
<xen:hook name="page_container_head">
	<meta charset="utf-8" />
	<xen:if is="{$requestPaths.fullBasePath}">
		<base href="{$requestPaths.fullBasePath}" />
		<script><xen:comment>/* Chrome bug and for Google cache */</xen:comment>
			var _b = document.getElementsByTagName('base')[0], _bH = "{xen:jsescape $requestPaths.fullBasePath}";
			if (_b && _b.href != _bH) _b.href = _bH;
		</script>
	</xen:if>

	<title><xen:if is="{$title}">{xen:raw $title} | {$xenOptions.boardTitle}<xen:else />{$xenOptions.boardTitle}</xen:if></title>
	
	<noscript><style>.JsOnly { display: none !important; }</style></noscript>
	<link rel="stylesheet" href="css.php?css=xenforo,form,public&amp;style={xen:urlencode $_styleId}&amp;dir={$visitorLanguage.text_direction}&amp;d={$visitorStyle.last_modified_date}" />
	<!--XenForo_Require:CSS-->	
	{xen:helper ignoredCss, {$visitor.ignoredUsers}}

	<xen:include template="google_analytics" />
	<xen:include template="page_container_js_head" />
	
	<link rel="alternate" type="application/rss+xml" title="{xen:phrase rss_feed_for_x, 'title={$xenOptions.boardTitle}'}" href="{xen:link forums/-/index.rss}" />
	<xen:if is="{$pageDescription.content} AND !{$pageDescription.skipmeta} AND !{$head.description}"><meta name="description" content="{xen:string wordTrim, {xen:helper stripHtml, {xen:raw $pageDescription.content}}, 200}" /></xen:if>
	<xen:if is="{$head}"><xen:foreach loop="$head" value="$headElement">{xen:raw $headElement}</xen:foreach></xen:if>
</xen:hook>

	<meta name="twitter:description" content="">
</head>
 

kingston

Well-known member
#5
I'm trying to set up the twitter card meta tags but I'm having problems with this one:

<meta name="twitter:description" content="">

I've tried:

<xen:if is="{$pageDescription.content} AND !{$pageDescription.skipmeta} AND !{$head.description}"><meta name="twitter:description" content="{xen:string wordTrim, {xen:helper stripHtml, {xen:raw $pageDescription.content}}, 200}"></xen:if>

and

<meta name="twitter:description" content="{xen:raw $pageDescription.content}">

but neither will output the description when I check the page source. Can anyone help with what I should use?
Where you able to get this to work? I want to add this to my forum. I have my forum auto post links when threads become Hot Threads (aka have enough views to warrant them being worthy of reposting). I really want the tweet to be a deeper tweet than just a link.
 

kingston

Well-known member
#6
There is no PAGECONTENT template. Do you mean PAGE_CONTAINER? Just add it to the head:

Code:
<!DOCTYPE html>
<html id="XenForo" lang="{$visitorLanguage.language_code}" dir="{$visitorLanguage.text_direction}" class="Public {xen:if {$visitor.user_id}, 'LoggedIn', 'LoggedOut'} {xen:if {$sidebar}, 'Sidebar', 'NoSidebar'}" xmlns:fb="http://www.facebook.com/2008/fbml">
<head>
<xen:hook name="page_container_head">
<meta charset="utf-8" />
<xen:if is="{$requestPaths.fullBasePath}">
<base href="{$requestPaths.fullBasePath}" />
<script><xen:comment>/* Chrome bug and for Google cache */</xen:comment>
var _b = document.getElementsByTagName('base')[0], _bH = "{xen:jsescape $requestPaths.fullBasePath}";
if (_b && _b.href != _bH) _b.href = _bH;
</script>
</xen:if>

<title><xen:if is="{$title}">{xen:raw $title} | {$xenOptions.boardTitle}<xen:else />{$xenOptions.boardTitle}</xen:if></title>

<noscript><style>.JsOnly { display: none !important; }</style></noscript>
<link rel="stylesheet" href="css.php?css=xenforo,form,public&amp;style={xen:urlencode $_styleId}&amp;dir={$visitorLanguage.text_direction}&amp;d={$visitorStyle.last_modified_date}" />
<!--XenForo_Require:CSS-->
{xen:helper ignoredCss, {$visitor.ignoredUsers}}

<xen:include template="google_analytics" />
<xen:include template="page_container_js_head" />

<link rel="alternate" type="application/rss+xml" title="{xen:phrase rss_feed_for_x, 'title={$xenOptions.boardTitle}'}" href="{xen:link forums/-/index.rss}" />
<xen:if is="{$pageDescription.content} AND !{$pageDescription.skipmeta} AND !{$head.description}"><meta name="description" content="{xen:string wordTrim, {xen:helper stripHtml, {xen:raw $pageDescription.content}}, 200}" /></xen:if>
<xen:if is="{$head}"><xen:foreach loop="$head" value="$headElement">{xen:raw $headElement}</xen:foreach></xen:if>
</xen:hook>

<meta name="twitter:description" content="">
</head>
Do you know how to do this?
 

akia

Well-known member
#9
Where you able to get this to work? I want to add this to my forum. I have my forum auto post links when threads become Hot Threads (aka have enough views to warrant them being worthy of reposting). I really want the tweet to be a deeper tweet than just a link.
No, I never was able to.
 

kingston

Well-known member
#10
You can set it up on your site that when you tweet a link it will create a twitter card. If you post a link to iTunes you can see a good example. From what I can tell this can be done by anyone. As there is options to share pages from Xenforo to Twitter I think it is a lot more engaging if there was a Twitter card for someones forum with the information shared.

https://dev.twitter.com/docs/cards
 

akia

Well-known member
#11
Just like with the Facebook Meta Tags, Twitter now have them.

Code:
<meta name="twitter:card" content="summary">
<meta name="twitter:site" content="@nytimes">
<meta name="twitter:creator" content="@SarahMaslinNir">
<meta name="twitter:title" content="Parade of Fans for Houston’s Funeral">
<meta name="twitter:description" content="NEWARK - The guest list and parade of limousines with celebrities emerging from them seemed more suited to a red carpet event in Hollywood or New York than than a gritty stretch of Sussex Avenue near the former site of the James M. Baxter Terrace public housing project here.">
<meta name="twitter:image" content="http://graphics8.nytimes.com/images/2012/02/19/us/19whitney-span/19whitney-span-article.jpg">
and its these I'm trying to get working.
 

akia

Well-known member
#12
There is no PAGECONTENT template. Do you mean PAGE_CONTAINER? Just add it to the head:

Code:
<!DOCTYPE html>
<html id="XenForo" lang="{$visitorLanguage.language_code}" dir="{$visitorLanguage.text_direction}" class="Public {xen:if {$visitor.user_id}, 'LoggedIn', 'LoggedOut'} {xen:if {$sidebar}, 'Sidebar', 'NoSidebar'}" xmlns:fb="http://www.facebook.com/2008/fbml">
<head>
<xen:hook name="page_container_head">
<meta charset="utf-8" />
<xen:if is="{$requestPaths.fullBasePath}">
<base href="{$requestPaths.fullBasePath}" />
<script><xen:comment>/* Chrome bug and for Google cache */</xen:comment>
var _b = document.getElementsByTagName('base')[0], _bH = "{xen:jsescape $requestPaths.fullBasePath}";
if (_b && _b.href != _bH) _b.href = _bH;
</script>
</xen:if>

<title><xen:if is="{$title}">{xen:raw $title} | {$xenOptions.boardTitle}<xen:else />{$xenOptions.boardTitle}</xen:if></title>

<noscript><style>.JsOnly { display: none !important; }</style></noscript>
<link rel="stylesheet" href="css.php?css=xenforo,form,public&amp;style={xen:urlencode $_styleId}&amp;dir={$visitorLanguage.text_direction}&amp;d={$visitorStyle.last_modified_date}" />
<!--XenForo_Require:CSS-->
{xen:helper ignoredCss, {$visitor.ignoredUsers}}

<xen:include template="google_analytics" />
<xen:include template="page_container_js_head" />

<link rel="alternate" type="application/rss+xml" title="{xen:phrase rss_feed_for_x, 'title={$xenOptions.boardTitle}'}" href="{xen:link forums/-/index.rss}" />
<xen:if is="{$pageDescription.content} AND !{$pageDescription.skipmeta} AND !{$head.description}"><meta name="description" content="{xen:string wordTrim, {xen:helper stripHtml, {xen:raw $pageDescription.content}}, 200}" /></xen:if>
<xen:if is="{$head}"><xen:foreach loop="$head" value="$headElement">{xen:raw $headElement}</xen:foreach></xen:if>
</xen:hook>

<meta name="twitter:description" content="">
</head>
I need to add the page meta description in the content bit.
 

akia

Well-known member
#13
Can no one help with this?

What variable would I need to use to be able to use the meta description tag text elsewhere in a different template.