Skip to content
Grav 2.0 is officially stable. Read the announcement →
Archive

Sharing on Facebook

Started by Muut Archive 10 years ago · 6 replies · 815 views
10 years ago

I would like to ask how to capture the photos with the description and blog title on facebook? When I copy the URL of passage. It shows the address only.

10 years ago

Thanks for your reply. But I would like to know which file(s) should I use?

10 years ago

In a site of mine I did this: in [mytheme]/templates/partials/base.html.twig I added

TWIG
    <meta name="og:url" property="og:url" content="https://mysite.com{{ page.url }}" />
    <meta name="og:title" property="og:title" content="{{ page.title }}" />
    <meta name="og:description" property="og:description" content="{{ page.metadata.description.content }}" />

and in each page I have set some custom metadata in the page header:

YAML
metadata:
    description: "the page description"
    "og:image": "https://mysite.com/mypage/myimage.jpg"

You can do it in various ways. You can also simply set your og:description to {{page.summary}} and og:image to {{page.media.images|first.url}} in your Twig, so you don't need to define them manually if you don't need that kind of granular control over the Facebook sharing output.

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1359 9 years ago
Archive · by Muut Archive, 9 years ago
2 936 9 years ago
Archive · by Muut Archive, 9 years ago
2 4066 9 years ago
Archive · by Muut Archive, 9 years ago
1 2956 9 years ago
Archive · by Muut Archive, 9 years ago
3 1121 9 years ago