I have the following code in the “main.twig” template:
<head>
{% block head %}
<meta property="og:image" content="{% block pageImage %}{% endblock %}" />
{% endblock %}
</head>
Then, I’m trying to populate the image URL into the < meta > tag from a Matrix field:
{% extends "templates/main" %}
{% for block in entry.articleBody %}
{% if block.type == "articleImage" %}
{% set image = block.articleImage.first().getUrl() %}
{% block pageImage %}{{ image }}{% endblock %}
{% endif %}
{% endfor %}
{% block head %}{{ parent() }}{% endblock %}
However, no URL is outputted. Does anyone know why?
Thanks!