OpenGraph Application

Last modified by Thomas Mortagne on 2022/11/07 00:06

cogAdds OpenGraph tags to page head.
TypeXAR
CategoryApplication
Developed by

slauriere, Manuel Leduc

Active Installs1
Rating
0 Votes
LicenseGNU Lesser General Public License 2.1
Compatibility

XWiki Standard 11.1

Installable with the Extension Manager

Description

This application adds OpenGraph support to XWiki page HTML head element. The Open Graph protocol enables any web page to become a rich object in a social graph. For instance, it is used to retrieve image to be displayed on Facebook, LinkedIn, Pinterest when publishing a web page to these sites.

This macro typically adds the elements below to the HTML head tag. The image elements are computed as follows: the extension first tries to include the URLs of the images attached to the current page, if any; otherwise it adds the URLs of images attached to the wiki home page, if any.

By default, the following metadata are added to the pages. Note that the description is only added since version 1.2.

<meta property="og:url" content="https://www.xwiki.org/xwiki/bin/view/Main/"/>
<meta property="og:type" content="article" />
<meta property="og:title" content="Home" />
<!-- One og:image meta element is added per image attachments of the page (or from the main page if the current page does not have attachments). -->
<meta property="og:image" content="https://www.xwiki.org/xwiki/bin/download/Main/WebHome/Earthrise1_Apollo8AndersWeigang_2048.jpg" />
<meta property="og:description" content="First characters of the content of the page..." />

The Facebook OpenGraph debugger can be useful for testing the output of this extension.

Meta entry customization

1.2+ 

Meta elements can be customized for a given page by adding XWiki.OpenGraph.Code.OpenGraphMetaClass XObjects to the page.

  • The Property field is automatically prefixed with og: if missing
  • Velocity can be used inside the content

Properties defined using XObjects are overriding automatically generated properties.

Prerequisites & Installation Instructions

We recommend using the Extension Manager to install this extension (Make sure that the text "Installable with the Extension Manager" is displayed at the top right location on this page to know if this extension can be installed with the Extension Manager). Note that installing Extensions when being offline is currently not supported and you'd need to use some complex manual method.

You can also use the following manual method, which is useful if this extension cannot be installed with the Extension Manager or if you're using an old version of XWiki that doesn't have the Extension Manager:

  1. Log in the wiki with a user having Administration rights
  2. Go to the Administration page and select the Import category
  3. Follow the on-screen instructions to upload the downloaded XAR
  4. Click on the uploaded XAR and follow the instructions
  5. You'll also need to install all dependent Extensions that are not already installed in your wiki

This application requires the user interface extension point org.xwiki.platform.html.head, which was introduced in XWiki 11.5. In order to add this extension point to a previous version of XWiki, go to the "Presentation" section of the wiki administration and add the following lines just below the final "meta" tag:

#foreach($uix in $services.uix.getExtensions("org.xwiki.platform.html.head", {'sortByParameter' : 'order'}))
  $services.rendering.render($uix.execute(), 'xhtml/1.0')
#end

Release Notes

v1.2.1

v1.2

Dependencies

Dependencies for this extension (org.xwiki.contrib:application-opengraph-ui 1.2.1):

Tags:
    

Get Connected