Skip to content

OpenGraph tags not recognized on initial share by Facebook for wiki pages #7832

Open
@jywarren

Description

@jywarren

Here is where we set our OpenGraph tags for sharing pages on social media; this sets the preview image, title, etc:

<% if @node && @node.body %>
<meta property="og:title" content="<%= @title %>" />
<meta property="og:site_name" content="Public Lab" />
<meta property="og:url" content="https://<%= request.host %>/n/<%= @node.id %>" />
<meta property="og:description" content="<%= raw strip_tags(sanitize(RDiscount.new(@node.body).to_html)).truncate(100) %>" />
<meta property="og:type" content="article" />
<meta property="fb:app_id" content="644692375883090" />
<% if @node.main_image %>
<meta property="og:image" content="https://<%= request.host %><%= @node.main_image.path(:default) %>" />
<meta name="twitter:image" content="https://<%= request.host %><%= @node.main_image.path(:default) %>">
<% end %>
<p class="facebook-summary" style="display:none;">
<%= raw strip_tags(sanitize(RDiscount.new(@node.body).to_html)).truncate(100) %>
</p>
<% end %>
<p class="facebook-summary" style="display:none;"><%= translation('layout._header.summary') %></p>
<!-- facebook needs this apparently -->
<div id="fb-root"></div>

The facebook summary line was changed here: #6734 so we may need to revert that but it's worth looking at "view source" for a page to see what it inserts.

Here is where we last edited these, i think: 3dad8ad

cc @joyofsoy

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugthe issue is regarding one of our programs which faces problems when a certain task is executedhelp wantedrequires help by anyone willing to contributewsused by staff for internal tracking

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions