Kirby, vimeo and facebook

I am embedding a video from vimeo on a Kirby page.

When a user share the page on facebook, there is a link to the page on a facebook, but the video is not embeded.

Is it possible to embed the video on facebook when this page is shared ?

(the page look like plus a video inside:

It’s fitting than when users share your page, what is actually shared in Facebook is, well, your page. :slight_smile:

Facebook is using Opengraph, a documented syntax they proposed, so you could try feeding it specific information to make it link to the video instead, if possible. You’ll have to explore different options and see what works.

Be warned that Facebook tends to cache their snippets for a given URL, so if you change the Opengraph metadata in the <head> of your page and try to post it to Facebook again, you’ll probably see the same snippet as before. One solution is to create a test page and change it’s folder name (and hence its URL) every time you run a test with different metadata.

You could try to give the Vimeo URL as the canonical URL for your page. Or maybe just using og:video with the URL to the Vimeo page might work. Or something else altogether.

In any case, if you do use Opengraph, you will need to add tags in the page’s head, perhaps using values from some of the page’s fields, for instance if some pages have a “VideoUrl” field:

<?php if (!$page->videourl()->empty()): ?>
    <meta property="og:video" content="<?= $page->videourl() ?>">
<?php endif; ?>
1 Like

What also might help to see what Facebook gets from your site and if it thinks something would be wrong:

1 Like