Dynamic page URL and image URL in metatag

In the docs (https://learn.getgrav.org/content/headers#meta-page-headers), I see that we need to hard-code the URL of the page and the URL of the image for Facebook and Twitter metatags.

Is there any way we can do this automatically? For image, maybe we get the first image, similar to what we do in Twig {{ page.media.images|first.url }} as use it as og:image and twitter:image.

@hungtran I’m sure @rhukster will answer you.

Before some days there was a Metadata Extended plugin, which has allowed you to use Twig in metadata variables. Unfortunately this plugin was deleted (but we have a backup up it). I was talking to @rhukster and he means that it will be a part of Grav core.

You may open an issue for that https://github.com/getgrav/grav so that we can keep track of it or wait for @rhukster’s response here.

I’ve already added functionality to Grav in the develop branch of GitHub ready for the upcoming release of Grav version 1.1.

Basically it will allow you to put Twig variables in the frontmatter. Mostly this is intended for config and site options, but ‘some’ page variables will work such as {{ page.url(true) }} to get the full URL of the page. The reason that not all page variables will work, is the frontmatter is processed first, and the Twig is processed even before the frontmatter. So the page is not fully formed yet.