Regarding Statamic

More About Open Graph and YouTube Thumbnails

Recorded on April 27th, 2016

Here’s Part 2 of what I started last night with the YouTube thumbnail issue. I knew from doing some reading that Facebook looks for an og:image Open Graph meta tag in your HTML when you share a post from your site. If you have an embedded YouTube video that you hope generates a thumbnail, you need a meta tag that looks something like this:

<meta property="og:image"  
content="http://i3.ytimg.com/vi/
wRnfXxsPQNQ/hqdefault.jpg" />  

I’m running this blog on Statamic, which has the handy ability to let you define a new field in the YAML at the top of the text file of your post, like this. I called my static image URL field my_og_image:

---
title: 'Public Service Announcement: I've Got A Knife'. categories: [ music, safety first ]
my_og_image: http://i3.ytimg.com/vi/wRnfXxsPQNQ/hqdefault.jpg
---

And then, to make it show up in every post, you add this to Statamic’s _themes/THEME_NAME_HERE/layouts/default.html  file:

<meta property="og:image"  
content="{{ my_og_image }}" />

That’s technically not the entirely correct way to do it, because it’s not conditionally adding the meta tag. If you don’t define a value for my_og_image in your post’s YAML, you’re still going to get a meta tag for og:image and it’s going to be blank, which isn’t great. But I’m still learning about how to properly define fieldsets and stuff in Statamic, so I hope to figure that out later. This will work well enough for me now.

I Don’t Get Text Encoding in Editorial/Python

Recorded on February 11th, 2016

For a week, I was using the Editorial FTP Upload workflow from Macdrifter, and then realized yesterday that the text encoding it was doing in this section was converting “>” characters to &gt; entities.

encode_string = cgi.escape(postContent).encode('ascii', 'xmlcharrefreplace')

I think this is what messes up Markdown blockquotes when Statamic renders a page. It also prevents passing any HTML through Markdown, which you’re supposed to be able to do if you need to.

I tried a bunch of stuff, changing the encoding from xmlcharrefreplace to replace or ignore, but I had no idea what I was doing, and tampering with encoding when you don’t know Python seems like a bad idea. In the end, I switched to Gabe’s alternative SFTP Upload, since it accomplishes the same thing but doesn’t confuse Statamic with the encoding.