A series of social media icons displayed on a smart phone screen.

Getting Facebook and Twitter to Display Primary Image from Articles

Step 1: Enable Open Graph & Twitter Card Modules

Please note: this step requires the user to be a Site Builder. If you do not have this role, please email the SiteFarm team for assistance in completing this step for you.
Metatag list updated November 19, 2021
  1. From the admin panel, click on Manage » Extend.
  2. Enable Metatag: Twitter Cards, Metatag: Open Graph, and Metatag: Facebook:
    The list of the three metatag modules that need to be enabled to make images display correctly on social media platforms.
  3. Clear your site cache using Shortcuts » SiteFarm Config » Clear Caches.

Step 2: Acquire a Developer account on Facebook

Configuring your content correctly for Facebook requires that you obtain an 'app id'. To do so, you will need to register your page per the Facebook Developer resources. This will take you to the developer.facebook.com page using the Get Started button in the upper right corner. Follow the instructions and note the 'app id' generated for your account.

Step 3: Configure Metatag Modules

[Updated October 2019]

  1. If you would like, for reference only, you can open Manage » Help and then, under Module Overviews, click on Token to see a complete list of the available Tokens in SiteFarm. No changes to this page are necessary.
    A list of available Help topics with the link to the Token page encircled to make it easier to find in the list.
  2. Go to the end of your site domain (example: https://sitefarm.ucdavis.edu/ or http://yoursite.sf.ucdavis.edu) in the browser field and type or paste in /admin/config/search/metatag/node. NOTE: make sure to include the square brackets indicated [ token ] as shown below.
    • Under BASIC Tags
      • > Page title add the tokens:
        [node:title] | [site:name]
      • > Description add the token:
    • Under ADVANCED
      • > Image add the token:
    • Under OPEN GRAPH
      • > Content Type add the text:
      • > Page URL add the token:
      • > Title add the token:
      • > Description add the token:
      • > Image add the token:
      • > Image type add the token:
      • > Image width: 1280
      • > Image height: 720
      • > Image 'alt' add the token:
      • > Content modification date & time add the token:
      • > Article author
      • > Article section
      • > Article tags
      • > Article publication date & time
      • > Article modification date & time
    • Under FACEBOOK
      • > Facebook Application ID  add:
        the 'app id' provided in Step 2
      • Twitter Card type: Photo card
      • > Description add the token:
      • > Site's Twitter Account
        Your account details
      • > Title add the token:
      • > Page URL
      • > Image URL add the token:
      • > Image alternative text add the token:
      • > Image height: 720
      • > Image width: 1280 
  3. Click Save to finish.

Step 4: Test your work

  1. Go to Twitter Card Validator.
  2. Enter the URL of one of your article pages you want to test.
  3. Click the Preview Card button which will show you an example output. With the settings entered above, you will see your twitter account name, the article's image and title.
    Example of a successful Twitter Card output.
    Example of a successful Twitter Card output.
  4. Go to Facebook debugger.
  5. Paste in the URL of a piece of content shared to Facebook.
  6. Go to LinkedIn's Post Inspector. Please note you'll be required to log into your account first.
  7. Paste in the URL of a piece of content shared to LinkedIn.
  8. Use Iframely's all-in-one debugger, which also include origin data outputs.


Important Notes & Troubleshooting

  • If you make a change to your token and do not notice a change in the debug screen, try editing and re-saving your page in your SiteFarm site so the new token is applied.
  • If you test your Twitter share button and the post isn't including a link to your article, make sure to provide a teaser sentence or two to the Summary field, which is located right next to the Body label above the WYSIWYG. If the Summary field isn't being used, the ShareThis module pulls an arbitrary amount of text from the beginning of your article, but that amount exceeds the allowable character count. Including your own Summary allows you to control the teaser, which is used through out your SiteFarm site and on social media platforms.

Primary Category