Sharing content on Twitter and Facebook with Perch

If you have ever shared a blog post on Facebook and wondered why a strange image was picked off your site to illustrate it, you’ll be happy to know that Perch can help you customize what social sites use when your content is shared.

The Page Attributes feature in Perch allows you to create templated content that is tied to particular pages of your site. The default included template includes SEO data, such as the meta description. You can use this functionality to add your Facebook Open Graph tags and create a Twitter Summary or other card.

In Perch 2.7.4 we have added a feature to override these attributes from PHP – this is really useful if you want to push data from a blog post into them. You can push the blog post title, excerpt and feature image or add additional fields to really tailor the content that is shown when a post is shared.

In the Solutions section of the documentation we’ve added a post walking you through adding these tags to regular pages and also the blog in Perch and Perch Runway. Read Using Page Attributes to add Facebook Open Graph Tags and Twitter Cards for details of how to implement this on your own sites.