Reputation: 93
I've tweaked my template multiple times to try to make this work, but I can't seem to find a solution. Since I don't post with individual search descriptions, every post's meta description just uses the blog's main meta description each time. So is there a way to override this and at least get a meta description from the data:post.snippet variable? Someone also asked a question about this here a few years ago, but there was never a solution for it.
I currently have these codes that have the metaDescription variable. First, I added this manually in the head:
<!-- Open Graph Meta Tags BEGIN -->
<b:if cond='data:blog.metaDescription'>
<meta expr:content='data:blog.metaDescription' property='og:description'/>
</b:if>
And this is at the very top of the body:
<b:if cond='data:blog.metaDescription'>
<meta expr:content='data:blog.metaDescription' itemprop='description'/>
</b:if>
And lastly, this is in post code in the body. So do I have to tweak this code in the post includable?
<b:if cond='data:blog.metaDescription == ""'>
<!-- Then use the post body as the schema.org description,
for good G+/FB snippeting. -->
<div class='post-body entry-content' expr:id='"post-body-" + data:post.id' itemprop='description articleBody'>
<data:post.body/>
<div style='clear: both;' />
<!-- clear for photos floats -->
</div>
<b:else/>
<div class='post-body entry-content' expr:id='"post-body-" + data:post.id' itemprop='articleBody'>
<data:post.body/>
<div style='clear: both;' />
<!-- clear for photos floats -->
</div>
What's interesting is I get the post's intro in my Twitter card's meta description when I put this at the top of the post code, so I'm not sure what I'm doing wrong.
<b:if cond='data:blog.metaDescription'>
<meta expr:content='data:blog.metaDescription' name='twitter:description' />
<b:else/>
<meta expr:content='data:post.snippet' name='twitter:description' />
</b:if>
Thanks in advance for the help!
Upvotes: 2
Views: 1605
Reputation: 309
As far as i know, data:post.snippet
would only work inside the Blog type widget (<b:widget type='Blog' id="somename">
).
In addition, that type of widget should only appear inside the section (<b:section>
) tag which is not allowed inside HTML's head
tags, else, this error should appear:
b:section should not appear inside of head
UPDATE: You can probably add these lines if you're bothered by this description issue:
<b:if cond='data:blog.metaDescription != ""'>
<meta expr:content='data:blog.metaDescription' property='og:description'/>
<b:else/>
<meta content='[INSERT A DESCRIPTION HERE]' property='og:description'/>
<b:if>
You can check this for a detailed description: Adding Open Graph Meta Tags to Blogger Blogs
Upvotes: 1