Blogger posts have no snippet


(João Pimentel Ferreira) #1

Any reason why the blogger posts do not generate a snippet?

For example, on this blogger post, I paste a URL, and merely the URL appears:

https://www.veraveritas.eu/2018/06/transportes-os-dados-que-os-economistas.html

But on Wordpress, normally, a snippet appears.

Which meta-info or HTML tags Discourse gets to generate a snippet?
Which information shall one have in a blogger post, such that a sinipet is generated?

thank you


(Rafael dos Santos Silva) #2

For testing we recommend using Iframely.

A typical blog post will have OpenGraph tags in the head seaction, like:

<meta property="og:site_name" content="Discourse Blog">
<meta property="og:url" content="https://blog.discourse.org/2018/05/discourse-2-0-released/">
<meta property="og:title" content="Discourse 2.0 released!">
<meta property="og:description" content="We released Discourse 2.0 on May 31st, building on Discourse 1.9 from January. New Admin Dashboard We’ve completely redesigned the admin dashboard to show off your most relevant and essential community health metrics right at the top, as well as trending searches. Shared Drafts Staff can designate a category for shared drafts, and pre-compose topics that only other staff can see for review prior to posting. After posting, all logged edits are removed so the history is clean, and the timestamp is reset, too. Reply mode toggle While composing a […]">

(João Pimentel Ferreira) #3

Thanks a lot. Apologies to ask again after this time, but I’ve been around trying to insert that on my blogger blog template

Does it take time to fetch/update?

The tester you suggested seems to fetch the code correctly but here the discourse still does not render the snippet.

https://www.veraveritas.eu/2014/04/ferrovia-ou-rodovia.html


(João Pimentel Ferreira) #4

Thanks, finally I solved everything.

For blogger, I used this code, which I inserted right before the tag </head> in the blogger’s template

    <!-- OpenGraph starts-->
    <meta content='article' property='og:type'/>
    <meta expr:content='data:blog.title' property='og:site_name'/>
    
	<!-- Title and URL -->
    <meta expr:content='data:blog.pageName' property='og:title'/>
    <meta expr:content='data:blog.canonicalUrl.https' property='og:url'/>
		
    <!-- Image -->
	<b:if cond='data:blog.postImageThumbnailUrl'>
		<meta expr:content='data:blog.postImageThumbnailUrl' property='og:image'/>
    <b:elseif cond='data:blog.postImageUrl'/>
    	<meta expr:content='data:blog.postImageUrl' property='og:image'/>    
	<b:else/>
    	<meta content='YOUR_LOGO_URL' property='og:image'/> 
    </b:if>

	<meta expr:content='&quot;pt_PT&quot;' property='og:locale'/>

    <!-- OpenGraph ends-->

The og:description is not fetched inside <head> since the variable data:post is not available in <head>. You must add in the template right after the line <data:post.body/> the following line:

<meta expr:content='data:post.snippet' property='og:description'/>

If you want a costumized snippet you may use this instead

<meta expr:content='snippet(data:post.body, { length: 150, links: false, linebreaks: false })' property='og:description'/>

now it seems to work smoothly, here’s a test :slight_smile: (please, it’s not spam, it’s merely a test showing that it does work here in discourse)