I'm using a matrix for hero images on my pages, and I'd like to use them as the SEO image in SEOMatic, but it's not available in the settings.

I tried setting the field to "Custom URL" and adding twig code:

{% set hero = entry.heroImages.one() %}{% set image = hero.image.one() %}{{ image.url }} 

If I place this in my template, it displays the path to the first matrix image, but SEOMatic seems to ignore it.

Is there another way to configure things to use my matrix images?

1 Answer 1


Since SEOmatic fields are parsed as object templates, you'll need to preface things like entry with object., e.g.:

{% set hero = object.entry.heroImages.one() %}{% set image = hero.image.one() %}{{ image.url }} 

c.f.: https://github.com/nystudio107/craft-seomatic#content-seo-control-panel-fields

Note that you could also do this entirely in your Twig template, like this:

{% set hero = entry.heroImages.one() %}
{% set image = hero.image.one() %}
{% do seomatic.meta.seoImage(image.url) %}
{% do seomatic.meta.twitterImage(image.url) %}
{% do seomatic.meta.ogImage(image.url) %}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.