Twitter Cards for Drupal - A brief how to

Twitter Card

Twitter cards are a great way to give tweets a media experience, enabling you to add images, summaries, videos or even detailed product information to a tweet. You can add Twitter cards to your Drupal site easily with the Meta Tags module - currently supporting summary, photo, and media player cards.

 

To enable Twitter cards firstly download, install and enable the Meta Tags module available here: http://drupal.org/project/metatag. Once done you can navigate to Configuration > Search and Metadata > Meta Tags to be presented with the defaults screen seen below.

Editing a default will allow you to change the default card type, and values (setting the summary text to use, image to use, site twitter account etc). All the defaults can be set using tokens you would with other areas of the site, i.e [node:field_image]. Now when you create a post you'll see the Twitter card option in the Meta Tags tab:

Expanding the 'Twitter card' to see all the defaults set above.

You can edit any of the options you need to for the post, submit it and you're done. Your page now has all the markup it needs to be seen as a Twitter card. Before it will appear as a Twitter card though you need to validate your domain. Start this by navigating to Twitters card validator tool here: https://dev.twitter.com/docs/cards/validation/validator. Click on the validate url tab, wack in your url and hit go. If all is well you'll see the below:

Once it validates you can click the 'request approval' button where you can send your domain to be approved for twitter cards. When sent you’ll get the message “Thanks for applying to be part of Twitter's cards service. We'll review your request as soon as possible. Expect a few weeks for turn-around time. You will receive an email when your request has been reviewed.”.

Mine took about four weeks to come through but it's well worth doing, moreso considering how easy it is.

Title image from http://blog.sharethis.com/