nystudio107 / craft-seomatic

SEOmatic facilitates modern SEO best practices & implementation for Craft CMS 3. It is a turnkey SEO system that is comprehensive, powerful, and flexible.
https://nystudio107.com/plugins/seomatic
Other
166 stars 71 forks source link

Set SEO image to image field in a matrix. #1503

Closed CreateSean closed 3 months ago

CreateSean commented 3 months ago

craft 5.3.4 SEOmatic 5.1.2

Question

I'm setting up content SEO on a new Craft 5 build -with content imported via feedme from a Craft 2 site. and I need to set the SEO Image source for SEOmatic to a image field in a matrix. How do I do that? Is this possible?

There will only ever be one matrix block with one image.

image

image

Additional context

Add any other context or screenshots about the support request here.

khalwat commented 3 months ago

Currently it's not possible to do this other than using custom Twig to do it, something roughly like:

{{ entry.myMatrix.one().assetfield.one().getUrl() }}
CreateSean commented 3 months ago

Two things,

I am unable to get that to work using:

{{ entry.hero.one().collectionImaage.one().getUrl() }}

second, when making changes to one entry type in the same section, the settings duplicate over to all other entry types.

So in the pages Channel I have entry type of Contact page and Our Team, I tried to set different options in the image setting but it whatever was saved last is applied to all entry types.

khalwat commented 3 months ago

Get it working in the page template for that section, and then paste the working code into the SEOmatic setting.

As for the entry types, you should be able to set settings on a per-entry type basis. There's a menu that lets you choose the entry type you're saving settings for.

CreateSean commented 3 months ago

weird that the entry types wasn't working yesterday but is today.

Have got this working in front end template {{ entry.hero.one().collectionImage.one().url }} but doesn't work in the SEOmatic settings

CreateSean commented 3 months ago

Additionally, I set up another section that has a dedicated image field - this is not being used as the SEO image as expected.

khalwat commented 3 months ago

Have you tried using the SEOmatic debug toolbar panel to see what the values look like for the variables on that page?

https://nystudio107.com/docs/seomatic/advanced.html#debug-toolbar

As for your second comment, can you give me more context? You're saying that pulling the image from a dedicated field is not working? Can you show screenshots of your SEOmatic settings?

Also did you set up the Global SEO settings to have a fallback image?

Is there an SEO Settings field that could be overriding things here?

CreateSean commented 3 months ago

So when I updated the global SEO image setting everything started working.

sorry for the hassle

khalwat commented 3 months ago

That sounds like a bug that I should address, though